question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: No module named setuptools (add details to docs)

See original GitHub issue

Users are getting “ImportError: No module named setuptools” when using pip to upgrade a package since distribute-0.7.3 was released.

e.g. when running a command like this: pip install --upgrade pyramid

Solution

To prevent the problem in new environments (that aren’t broken yet),

  1. First run pip install -U setuptools,
  2. Then run the command to upgrade your package (e.g. pip install --upgrade pyramid)

To fix the problem once it’s occurred, you’ll need to manually install the new setuptools, then rerun the upgrade that failed.

  1. Download ez_setup.py (https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py)
  2. Run python ez_setup.py
  3. Then rerun your upgrade (e.g. pip install --upgrade pyramid)

Also note that pip-1.4 (unreleased) has fixes to prevent this

Cause

distribute-0.7.3 is just an empty wrapper that only serves to require the new setuptools (setuptools>=0.7) so that it will be installed. (if you don’t know yet, the “new setuptools” is a merge of distribute and setuptools back into one project)

distribute-0.7.3 does it’s job well, when the upgrade is done in isolation. E.g. if you’re currently on distribute-0.6.X, then running pip install -U setuptools works fine to upgrade you to setuptools>=0.7.

The problem occurs when:

  1. you are currently using an older distribute (i.e. 0.6.X)
  2. and you try to use pip to upgrade a package that depends on setuptools or distribute.

As part of the upgrade process, pip builds an install list that ends up including distribute-0.7.3 and setuptools>=0.7 , but they can end up being separated by other dependencies in the list, so what can happen is this:

  1. pip uninstalls the existing distribute
  2. pip installs distribute-0.7.3 (which has no importable setuptools, that pip needs internally to function)
  3. pip moves onto install another dependency (before setuptools>=0.7) and is unable to proceed without the setuptools package

Note that pip-1.4 (unreleased) has fixes to prevent this. distribute-0.7.3 (or setuptools>=0.7) by themselves cannot prevent this kind of problem.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Reactions:20
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
StevenLOLcommented, Mar 8, 2016

fixed by

apt-get install --reinstall python-setuptools

0reactions
StevenLOLcommented, Mar 8, 2016

En same error again!!!

UBUNTU 15.10

python --version Python 2.7.10

sudo pip install pip -I

…successfully installed pip-8.1.0

sudo pip install setuptools

…Sucessfully … setuptools-20.2.2

sudo pip install protobuf -I

…Could not … … … No module named extern

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python 3: ImportError "No Module named Setuptools"
Your setup.py file needs setuptools . Some Python packages used to use distutils for distribution, but most now use setuptools , a more...
Read more >
[Fixed] ModuleNotFoundError: No module named 'setuptools'
Quick Fix: Python raises the ImportError: No module named 'setuptools' when it cannot find the library setuptools . The most frequent source of...
Read more >
Importerror no module named setuptools : Step By Step Fix
The Solution for the error importerror no module named setuptools is to install the setuptools proper packages and compatible versions.
Read more >
ImportError: No module named setuptools
ImportError : No module named setuptools. Sat Jun 29, 2013 2:49 am. I am trying to install xmpppy into my raspberry pi. when...
Read more >
No module named setuptools - Technical - Blockcerts Forum
ImportError : No module named setuptools ... We recommend using virtualenv [details](http://docs.python-guide.org/en/latest/dev/virtualenvs/) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found