ImportError: No module named setuptools (add details to docs)
See original GitHub issueUsers 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),
- First run
pip install -U setuptools
, - 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.
- Download
ez_setup.py
(https://bitbucket.org/pypa/setuptools/downloads/ez_setup.py) - Run
python ez_setup.py
- 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:
- you are currently using an older distribute (i.e. 0.6.X)
- 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:
- pip uninstalls the existing distribute
- pip installs distribute-0.7.3 (which has no importable setuptools, that pip needs internally to function)
- 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:
- Created 10 years ago
- Reactions:20
- Comments:6 (3 by maintainers)
Top GitHub Comments
fixed by
apt-get install --reinstall python-setuptools
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