问题描述
我使用sudo pip install virtualenv
,然后在目录中运行virtualenv ENV
时,我得到了Python 2虚拟环境.
I used sudo pip install virtualenv
, then when I run virtualenv ENV
in a directory, I get a Python 2 virtual enviroment.
如果我再次使用'pip3 install virtualenv'来安装virtualenv,它将覆盖先前安装的virtualenv,那么当我运行virtualenv ENV
时,我会得到Python 3虚拟环境吗?还是会在其他地方以不同的名称(例如virtualenv3)安装新的virtualenv?
If I use 'pip3 install virtualenv' to install virtualenv again, will it override the previous installation of virtualenv, then when I run virtualenv ENV
, I get a Python 3 virtual enviroment? or will it install a new virtualenv in a different name like virtualenv3 in a different place ?
推荐答案
您不需要花那么多的时间.您可以使用Python 2的virtualenv
创建Python 3虚拟环境.假设您在/usr/local/bin/python3
安装了Python 3的二进制文件,然后只需运行
You don't need to go to those lengths. You can use Python 2's virtualenv
to create a Python 3 virtual environment. Supposing you have Python 3's binary installed at /usr/local/bin/python3
then simply run
virtualenv -p /usr/local/bin/python3 ENV
您会发现
source ENV/bin/activate
为您提供所需的Python 3环境.
gives you the Python 3 environment you want.
这篇关于如果分别使用pip和pip3安装virtualenv,默认值为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!