I'm deploying a Django app to a dev server and am hitting this error when i run pip install requirements.txt:
Traceback (most recent call last):
File "/var/www/mydir/virtualenvs/dev/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
pkg_resources appears to be distributed with setuptools. Initially I thought this might not be installed to the python in the virtualenv so I installed setuptools (2.6, same version as Python) to the Python site-packages in the virtualenv with the following command
sh setuptools-0.6c11-py2.6.egg --install-dir /var/www/mydir/virtualenvs/dev/lib/python2.6/site-packages
EDIT This only happens inside the virtualenv. If I open a console outside the virtualenv then pkg_resources is present
but I am still getting the same error. Any ideas as to why pkg_resources is not on the path?
I use CentOS 6.7, and my python was just upgrade from 2.6.6 to 2.7.11, after tried so many different answer, finally the following one does the job:
Hope help someone in the same situation.
ImportError: No module named pkg_resources: the solution is to reinstall python pip using the following Command are under.
Step: 1 Login in root user.
Step: 2 Uninstall python-pip package if existing.
Step: 3 Download files using wget command(File download in
pwd
)Step: 4 Run python file.
Step: 5 Finaly exicute installation command.
Note: User must be root.
I experienced that error in my Google App Engine environment. And
pip install -t lib setuptools
fixed the issue.For me, this error was being caused because I had a subdirectory called "site"! I don't know if this is a pip bug or not, but I started with:
/some/dir/requirements.txt /some/dir/site/
pip install -r requirements.txt wouldn't work, giving me the above error!
renaming the subfolder from "site" to "src" fixed the problem! Maybe pip is looking for "site-packages"? Crazy.
It also happened to me. I think the problem will happen if the requirements.txt contains a "distribute" entry while the virtualenv uses setuptools. Pip will try to patch setuptools to make room for distribute, but unfortunately it will fail half way.
The easy solution is delete your current virtualenv then make a new virtualenv with --distribute argument.
An example if using virtualenvwrapper:
fixed it for me in Debian. Seems like uninstalling some .deb packages (twisted set in my case) has broken the path python uses to find packages