Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't pip install virtualenv in OS X 10.8 with brewed python 2.7

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?

like image 402
RogerFC Avatar asked May 31 '13 15:05

RogerFC


2 Answers

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
like image 113
metakermit Avatar answered Oct 11 '22 05:10

metakermit


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.

like image 32
Diaa Mohamed Kasem Avatar answered Oct 11 '22 06:10

Diaa Mohamed Kasem