简体   繁体   English

Python3 virtualenv和Django模块

[英]Python3 virtualenv and Django module

I have installed Python3. 我已经安装了Python3。 I created a virtual environment to point to the new version and installed Django which is using python3. 我创建了一个虚拟环境以指向新版本,并安装了使用python3的Django。 But when I am trying to use Django from the virtual environment, I am getting an error message: 但是,当我尝试从虚拟环境中使用Django时,出现一条错误消息:

ImportError: No module named 'django' ImportError:没有名为“ django”的模块

source activate
sudo pip install django
python -c "import django;"

屏幕截图

Don't use sudo when using virtualenv , just use pip will do the installation. 使用virtualenv时不要使用sudo ,只需使用pip进行安装。

Because sudo pip install will install into your global python, not the virtualenv. 因为sudo pip install将安装到全局python中,而不是virtualenv中。

You must install Django for your Virtualenv. 您必须为Virtualenv安装Django。 After use "source activate" you must run "pip install django". 使用“源激活”后,必须运行“ pip install django”。

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

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