Error No module named pkg resources

0 votes

I'm deploying a Django app to a dev server and am hitting this error when I run pip install -r 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
Jun 26, 2020 in Python by kartik
• 37,520 points
3,930 views

1 answer to this question.

0 votes

Hello @kartik,

This error occur 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:

$ deactivate
$ rmvirtualenv yourenv
$ mkvirtualenv yourenv --distribute
$ workon yourenv
$ pip install -r requirements.txt

Hope it helps!!

Thank You!

answered Jun 26, 2020 by Niroj
• 82,840 points

Related Questions In Python

0 votes
1 answer

Python error "ImportError: No module named pygame.locals"

You need to download and install the ...READ MORE

answered Jun 18, 2019 in Python by Greg
7,038 views
0 votes
2 answers

Python error " import requests ImportError: No module named requests"

Hello, Open Cmd or Powershell as Admin. type pip ...READ MORE

answered Nov 28, 2020 in Python by Rohan
• 200 points
17,483 views
0 votes
1 answer
0 votes
2 answers

Python error "ImportError: No module named 'tkinter'"

sudo apt-get install python3-tk Then, >> import tkinter # ...READ MORE

answered Nov 9, 2019 in Python by Icetutor
• 160 points
24,725 views
0 votes
1 answer

ImportError: No module named django_extensions

Hello @kartik, You can solve this error by ...READ MORE

answered Jun 25, 2020 in Python by Niroj
• 82,840 points
6,426 views
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,840 points
2,510 views
0 votes
1 answer

Import Error: No module named numpy?

Hello, I had numpy installed on the same ...READ MORE

answered Apr 14, 2020 in Python by Niroj
• 82,840 points
12,887 views
0 votes
2 answers

Python error “ImportError: No module named”

use the dir() function for particular import ...READ MORE

answered Jun 6, 2020 in Python by sahil
• 500 points
16,112 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP