使用python虚拟环境配置pycharm

It will show you how to configure PyCharm to work with Python in a virtual environment. Also you will configure the requirements.txt.

它将向您展示如何配置PyCharm以在虚拟环境中使用Python。 另外,您将配置requirements.txt。

Start PyCharm create a new project or clone it from your repository. As an example I created a file first_example.py to write inside the main. I specify that this is only an example and for reasons of brevity does not follow the structure of a Python project.

启动PyCharm创建一个新项目或从您的存储库中克隆它。 作为示例,我创建了一个文件first_example.py写入main内部。 我指定这只是一个示例,为了简洁起见,它不遵循Python项目的结构。

安装Python (Install Python)

First, make sure Python 3 is installed by running the following command:

首先,通过运行以下命令确保安装了Python 3:

python --version
python3 --version

If python 2 and 3 is installed, the output will be the installed version of python 2 and 3.

如果安装了python 2和3,则输出将是python 2和3的安装版本。

Image for post

If python is not installed, run the command and choose version 3.6 for example¹:

如果未安装python,请运行命令并选择版本3.6,例如¹:

sudo apt-get install python3.6
sudo apt install python3-pip python3-venv

Create virtualenv with:

使用以下命令创建virtualenv:

python3 -m venv <venv-directory>

It is possible to create virtualenv on the same directory or on a different directory. In this article I use the same directory as the project directory. In my case i call the directory “venv”, but we can use “any_name”:

可以在同一目录或不同目录上创建virtualenv。 在本文中,我使用与项目目录相同的目录。 就我而言,我将目录称为“ venv”,但我们可以使用“ any_name”:

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值