[英]Error when creating a python3 virtualenvwrapper
I have a python2.7 virtual environment already setup for an existing project but now I need to have a python3 virtual environment setup too.我已经为现有项目设置了 python2.7 虚拟环境,但现在我也需要设置 python3 虚拟环境。
The command that I am using to achieve this is (I already have python3 installed):我用来实现这一点的命令是(我已经安装了 python3):
which python3
returns /usr/bin/python3
which python3
返回/usr/bin/python3
mkvirtualenv --python=/usr/bin/python3 nameOfEnvironment
However, when I run the above command I get the error,但是,当我运行上述命令时,我得到了错误,
Running virtualenv with interpreter /usr/bin/python3
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/virtualenv.py", line 24, in <module>
import distutils.spawn
ModuleNotFoundError: No module named 'distutils.spawn'
How do I fix this problem and why is it looking at python2.7 when I've specified python3?我该如何解决这个问题,为什么当我指定 python3 时它会查看 python2.7? Does it have anything to do with the existing python2.7 virtual environment?跟现有的python2.7虚拟环境有关系吗?
Your mkvirtualenv is for version 2.7.您的 mkvirtualenv 适用于 2.7 版。
Install virtualenvwrapper using pip under python3 (use pip3 to be sure)在python3下使用pip安装virtualenvwrapper(使用pip3确定)
Ended up installing pip3 and installing virtualwrapper with pip3.最终安装 pip3 并使用 pip3 安装 virtualwrapper。
sudo apt install python3-pip
sudo pip3 install virtualenvwrapper
And then I reran bashrc
然后我重新运行bashrc
source ~/.bashrc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.