Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
qwcode opened this issue Jul 19, 2013 · 6 comments
Closed

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

qwcode opened this issue Jul 19, 2013 · 6 comments
Labels
auto-locked Outdated issues that have been locked by automation project: setuptools Related to setuptools type: docs Documentation related
Milestone

Comments

@qwcode
Copy link
Contributor

qwcode commented Jul 19, 2013

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.

@mattolson
Copy link

Just ran into this installing supervisor via the Opscode recipe. Any workarounds?

Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of pip install  --upgrade supervisor ----
STDOUT: Downloading/unpacking supervisor
  Running setup.py egg_info for package supervisor

Downloading/unpacking distribute from https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip#md5=c6c59594a7b180af57af8a0cc0cf5b4a (from supervisor)
  Running setup.py egg_info for package distribute

Downloading/unpacking meld3>=0.6.5 (from supervisor)
  Running setup.py egg_info for package meld3

Downloading/unpacking setuptools>=0.7 (from distribute->supervisor)
  Running setup.py egg_info for package setuptools

Installing collected packages: supervisor, distribute, meld3, setuptools
  Running setup.py install for supervisor

    Skipping installation of /usr/local/lib/python2.7/dist-packages/supervisor/__init__.py (namespace package)
    Installing /usr/local/lib/python2.7/dist-packages/supervisor-3.0b2-py2.7-nspkg.pth
    Installing echo_supervisord_conf script to /usr/local/bin
    Installing pidproxy script to /usr/local/bin
    Installing supervisorctl script to /usr/local/bin
    Installing supervisord script to /usr/local/bin
  Found existing installation: distribute 0.6.49
    Uninstalling distribute:
      Successfully uninstalled distribute
  Running setup.py install for distribute

  Running setup.py install for meld3
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    ImportError: No module named setuptools
    Complete output from command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build-root/meld3/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-Q5i6NO-record/install-record.txt --single-version-externally-managed:
    Traceback (most recent call last):

  File "<string>", line 1, in <module>

ImportError: No module named setuptools

@qwcode
Copy link
Contributor Author

qwcode commented Jul 23, 2013

yes, see the solution section in the description.

@qwcode
Copy link
Contributor Author

qwcode commented Aug 6, 2013

Jannis asked us to work the text from the description into the docs to make it more likely to be found

@qwcode
Copy link
Contributor Author

qwcode commented Aug 7, 2013

added a cookbook entry for this:
1e9202a

@StevenLOL
Copy link

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

@StevenLOL
Copy link

fixed by

apt-get install --reinstall python-setuptools

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation project: setuptools Related to setuptools type: docs Documentation related
Projects
None yet
Development

No branches or pull requests

3 participants