Although using pip install --upgrade setuptools to upgrade from distribute to setuptools works in isolation, it’s possible to get “ImportError: No module named setuptools” when using pip<1.4 to upgrade a package that depends on setuptools or distribute.
e.g. when running a command like this: pip install –upgrade pyramid
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)
- Upgrade pip using get-pip
- 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.
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 its 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:
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:
Note that pip v1.4 has fixes to prevent this. distribute-0.7.3 (or setuptools>=0.7) by themselves cannot prevent this kind of problem.