Russell Dias
Russell Dias

Reputation: 73382

Using Python's Pip in Virtualenv

I have been using Heroku's cedar stack with Python for some time now, without any errors. Today, however, when I decided to update my dependencies locally, within my virtualenv via sudo bin/pip install -r requirements I received the following error:

Traceback (most recent call last):
  File "/Users/alex/Desktop/dev/warren/warren/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 698, in <module>
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 701, in Environment
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 96, in get_supported_platform
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg/pkg_resources.py", line 221, in get_build_platform
  File "/Users/alex/Desktop/dev/warren/warren/lib/python2.6/distutils/__init__.py", line 16, in <module>
    exec(open(os.path.join(distutils_path, '__init__.py')).read())
IOError: [Errno 2] No such file or directory: '/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/__init__.py'

I suspected this had something to do with my upgrade to Lion (as pointed out by this question), but as mentioned in that question I have also updated Xcode, but the problem persists.

When I try to cd into the above directory there is no __init__.py file, in fact there is no .py files at all, just .pyo and .pyc files.

Upvotes: 1

Views: 707

Answers (1)

CraigKerstiens
CraigKerstiens

Reputation: 5979

The error message you're receiving is due to the link you that virtualenv created to your system python. You'll now want to destroy the virtualenv and recreate it. To destroy it you'll want to:

rm -r bin
rm -r include
rm -r lib
rm .Python

Then you should be able to re-create your virtualenv and then pip install your requirements.txt

Upvotes: 4

Related Questions