Ben Roberts Ben Roberts - 1 year ago 154
Python Question

pip install into virtualenv from github using -e option fails to add package to python path

I am trying to install a package from my github in "editable" (-e) mode to be able to easily work on the repository whilst using it.

However it is causing problems because its not available in the python path after I install it.

With a fresh, clean virtualenv "publisher" created and activated, I run the following:

pip install -e git+
Obtaining easy-thumbnails from git+
Cloning to /Users/ben/Envs/publisher/src/easy-thumbnails
Running egg_info for package easy-thumbnails

no previously-included directories found matching 'docs/_build'
Installing collected packages: easy-thumbnails
Running develop for easy-thumbnails

no previously-included directories found matching 'docs/_build'
Creating /Users/ben/Envs/publisher/lib/python2.7/site-packages/easy-thumbnails.egg-link (link to .)
Adding easy-thumbnails 1.2 to easy-install.pth file

Installed /Users/ben/Envs/publisher/src/easy-thumbnails
Successfully installed easy-thumbnails
Cleaning up...

Then if I run python (still in my virtualenv) and try to import anything from that package, It fails.

Python 2.7.2 (default, Jun 20 2012, 16:23:33)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import easy_thumbnails
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named easy_thumbnails

If I install it without the -e option, everything works dandy. I get the same effect (i.e. they aren't on the python path after installing them) with other repo's, e.g.
pip install -e git+
. So what gives?

One thing I'm noticing is that it doesn't seem to be actually updating the easy-install.pth file even though it says it is... something odd going on here.

But if i run it (the pip install... command) with sudo, it works! Also I can install the package globally (outside the virtualenv, with sudo of course) and that works.


Mac OSX 10.8.2

Answer Source

Although it addresses a different issue, following this Mac OSX 10.8-specific thread to its conclusion seemed to solve the problem for me.

Specifically, I installed distribute not using pip:

$ curl -O
$ python

Then I added export VIRTUALENV_DISTRIBUTE=1 to my ~/.bashrc file and restarted my terminals.

I uninstalled and reinstalled virtualenv and virtualenvwrapper just to be safe.

Then I destroyed my old virtual env's and recreated them. For whatever reason, fixing up virtualenv to use and install distribute fixes the problem. Wacky.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download