virtualenvwrapper似乎无视VIRTUALENVWRAPPER_PYTHON

时间:2016-04-19 20:21:00

标签: macos python-2.7 python-3.x virtualenv virtualenvwrapper

我是python / virtualenv n00b,并尝试按照说明安装virtualenv / virtualenvwrapper.sh。

我通过以下方式安装了virtualenv和virtualenvwrapper.sh:

pip install virtualenv
pip install virtualenvwrapper

我的系统上安装了python3.5和python2.7(Mac OS X El Capitan 10.11.4)

当我通过bash搜索python,python3,virtualenv和virtualenvwrapper.sh时,我得到以下内容:

which python ==> /usr/local/bin/python
which python3 ==> /usr/local/bin/python3
which virtualenv ==> /usr/local/bin/virtualenv
which virtualenvwrapper.sh ==> /usr/local/bin/virtualenvwrapper.sh

我将以下行添加到.bash_profile:

export PATH=/usr/local/bin:$PATH
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel

来源/usr/local/bin/virtualenvwrapper.sh

我的.bashrc文件基本上是空的,我的.profile来源我的.bash_profile。

当我尝试使用virtualenvwrapper.sh命令(例如'mkvirtualenv'和'lsvirtualenv')时,它们可以工作,但默认的python仍然是python 2.7。

当我运行mkvirtualenv -p python3.5 [name]时,默认的python正常工作(即python 3.5)。

我做错了什么?为什么virtualenvwrapper会识别指定的VIRTUALENVWRAPPER_PYTHON?

提前感谢您的帮助。真的很感激

~~~~ 我试过了: pip3 install virtualenv 并得到以下错误:

Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3138, in <module>
@_call_aside
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3124, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3151, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 663, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 676, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 849, in resolve raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==8.0.2' distribution was  
not found and is required by the application

1 个答案:

答案 0 :(得分:0)

如果有python3命令,应该有一个pip3命令。如果没有pip3,则只能为python 2.x安装pip。 pip3将安装到python3,pip将安装到python。

尝试使用pip3安装virtualenv和virtualenvwrapper。