When trying to install virtualenv using a brewed python, I get the following error:
$ pip install virtualenv
Requirement already satisfied (use --upgrade to upgrade): \
virtualenv in /Library/Python/2.7/site-packages/virtualenv-1.9.1-py2.7.egg
Cleaning up...
So clearly pip is somehow looking into the system python folder instead of the brewed one in /usr/local. How can I avoid this?
The brew doctor finds no problems, and the path priority is set ok.
I tried to remove the virtualenv package from the system python, so I could install virtualenv with the brewed pip. But then I could not create virtualenvs, as I got this error:
$ virtualenv datatransfer/
Traceback (most recent call last):
File "/usr/local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: virtualenv==1.9.1
So I have not managed to avoid the system virtualenv.
What I am doing wrong?
I had the same problem and I managed to solve it by uninstalling any brew versions of Python and virtualenv
brew uninstall python
brew uninstall pyenv-virtualenv
Manually moving all the virtualenv* files I found under /usr/local/bin
to another folder
sudo mkdir /usr/local/bin/venv-old
sudo mv /usr/local/bin/virtualenv* /usr/local/bin/venv-old/
Opening a new terminal tab and double-checking that I'm in a clean state
which python # => /usr/bin/python
which virtualenv # => virtualenv not found
And installing Python and virtualenv(wrapper) cleanly using the recommended method (here and here):
brew install python --with-brewed-openssl
# Open a new terminal tab now (to access /usr/local/bin/python)
pip install virtualenv
pip install virtualenvwrapper
I had the same issue,
for me
sudo mv /usr/local/bin/virtualenv* /usr/local/bin/venv-old/
the
pip install -I virtualenv
I didn't have to uninstall and reinstall python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With