简体   繁体   English

关于virtualenv和python版本?

[英]About virtualenv and version of python?

I need help in understanding with venv. 我需要帮助来了解venv。 I have installed venv with virtualenv venv -p python3.6. 我已经用virtualenv venv -p python3.6.安装了virtualenv venv -p python3.6. I have activated it (venv) and install django 我已经激活了它(venv)并安装了django

pip django`install django`

And so, when I work with my project should I always activate venv or not? 因此,当我处理项目时,是否应该始终激活venv? Because I run my manage.py without venv and using python2, but I need python3. 因为我没有venv并使用python2运行我的manage.py,但是我需要python3。 And then I run with active venv with python3 I got mistakes like this: 然后我用python3在活动venv上运行时遇到了这样的错误:

ModuleNotFoundError: No module named 'forms'

I also use python3.5.2 and I created a virtual environment using the following command 我也使用python3.5.2,并使用以下命令创建了虚拟环境

python3 -m venv venv

And activated it using the following command 并使用以下命令将其激活

. venv/bin/activate

I always activate the virtual environment before running the application 我总是在运行应用程序之前激活虚拟环境

您必须在调用pip install ... (可能在Python 3.x中使用pip3 )之前以及每次需要使用virtualenv时(例如,在调用python manage.py ...之前)激活virtualenv python manage.py ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM