I am python / virtualenv n00b, and tried to follow the instructions for installing virtualenv / virtualenvwrapper.sh.
I installed both virtualenv and virtualenvwrapper.sh via:
pip install virtualenv
pip install virtualenvwrapper
I have python3.5 and python2.7 installed on my system (Mac OS X El Capitan 10.11.4)
When I search for python, python3, virtualenv and virtualenvwrapper.sh via bash I get the following:
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
I add the following lines to my .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
source /usr/local/bin/virtualenvwrapper.sh
My .bashrc file is essentially empty, and my .profile sources my .bash_profile.
When I try to use virtualenvwrapper.sh commands (e.g., 'mkvirtualenv' and 'lsvirtualenv'), they work, but the default python is still python 2.7.
When I run mkvirtualenv -p python3.5 [name], the default python works correctly (i.e., python 3.5).
What am I doing wrong? Why is virtualenvwrapper recognizing the specified VIRTUALENVWRAPPER_PYTHON?
Thanks in advance for the help. Really appreciate it
~~~~
I tried:
pip3 install virtualenv
and got the following error:
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
If there is a python3 command, there should be a pip3 command. If there is no pip3, pip might only be installed for python 2.x. pip3 will install to python3, pip will install to python.
Try installing virtualenv and virtualenvwrapper with pip3.
来源:https://stackoverflow.com/questions/36728652/virtualenvwrapper-seemingly-ignoring-virtualenvwrapper-python