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 issue,
for me
the
I didn't have to uninstall and reinstall python.
I found that unlike you my paths were wrong according to brew doctor. But after correcting that I still had the issue (no surprises given your description) so I uninstalled virtualenv then reinstalled but this time with sudo,
sudo pip install virtualenv
This resolved the issue, which indicates that I've either got another problem with the system configuration in general or someone who has more then my one hour of Python experience will be able to point out why it's not good (I think it's related to global installing being considered a bad practice).
Seth is onto something with
which
seems you see the same as me,~ which python
results in/usr/local/bin/python
~ ls -l /usr/local/bin/python
gives me_permissions_etc_ /usr/local/bin/python -> ../Cellar/python/2.7.5/bin/python
Pip
which pip
pointed to/usr/local/bin/pip
ls -l /usr/local/bin/pip
shows_permissions_etc_ /usr/local/bin/pip -> ../Cellar/python/2.7.5/bin/pip
Virtualenv (I don't have an output prior to the sudo pip install)
which virtualenv
is/usr/local/bin/virtualenv
ls -l /usr/local/bin/virtualenv
shows_permissions_etc_ /usr/local/bin/virtualenv
When I created and use a virtualenv I get the following,
FWIW my .zshrc has the following,
What really caused and issue for me was the presence of
.pydistutils.cfg
in my$HOME
directory. That's what forced me to have to use:sudo pip install <package>
.If you ever have to use
sudo
to install a package viapip
, you're doing it wrong and you need to start troubleshooting your system right away; else everything is going to fail and you won't know why.Running:
brew doctor
will warn you about the.pydistutils.cfg
file, so don't forget to monitor the status of that command after making core changes to your system.It took me quite a while to track this down, but all is well now. This really helped
I had the same problem and found the solution on a Google group. It seems that /usr/local/bin/virtualenv was not updated so if you open it, you will see a reference to the old virtualenv 1.9.1 when a newer version has been installed on your system.
So you just need to open /usr/local/bin/virtualenv and replace it with:
And that worked for me!
Source: https://groups.google.com/forum/#!topic/python-virtualenv/hL_QDPJsnuY
I had the same problem and I managed to solve it by uninstalling any brew versions of Python and virtualenv
Manually moving all the virtualenv* files I found under
/usr/local/bin
to another folderOpening a new terminal tab and double-checking that I'm in a clean state
And installing Python and virtualenv(wrapper) cleanly using the recommended method (here and here):