how to upgrade python setuptools > 12.2 on ubuntu 15.04
Mia Lopez
The apt package seems to be 12.2
If I run sudo pip install -U setuptools the version seems to still be stuck at 12.2
$ python
>>> import pkg_resources
>>> r = pkg_resources.require(["setuptools"])[0]
>>> print("setuptools version: %s" % r.version)
setuptools version: 12.2[EDIT]
Just noticed it's won't overwrite the OS version of setuptools:
Downloading/unpacking pip from Downloading pip-7.1.2-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Downloading/unpacking setuptools from Downloading setuptools-18.3.2-py2.py3-none-any.whl (462kB): 462kB downloaded
Installing collected packages: pip, setuptools Found existing installation: pip 1.5.6 Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS Found existing installation: setuptools 12.2 Not uninstalling setuptools at /usr/lib/python2.7/dist-packages, owned by OS
Successfully installed pip setuptools
Cleaning up...[/EDIT]
22 Answers
Remove the repository version
sudo apt-get remove python-setuptoolsIf necessary, install
pipagainwget sudo -H python get-pip.pyInstall
setuptoolsviapipsudo -H pip install -U pip setuptools
And now, start you test again
% python
Python 2.7.9 (default, Apr 2 2015, 15:33:21)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pkg_resources
>>> r = pkg_resources.require(["setuptools"])[0]
>>> print("setuptools version: %s" % r.version)
setuptools version: 18.3.2Note
Installing any package that depends on either python-setuptools or python-pip will bring these packages back, so you may have to repeat this procedure!
The solution proposed by A.B. may not quite be enough: in recent version of setuptools, pkg_resources is a package, whereas previously it was just a single module.
Updating setuptools in the way described will leave a stale pkg_resources.py{,c} around, which may lead to the following error when importing setuptools:
AttributeError: 'module' object has no attribute 'packaging'To remove it, do the following:
Find out where the outdated
pkg_resourcesmodule is located:$ python -c 'import pkg_resources; print(pkg_resources.__file__)' /usr/lib/python2.7/dist-packages/pkg_resources.pycRemove this file and its
.pyfile:$ sudo rm /usr/lib/python2.7/dist-packages/pkg_resources.py*
Warning
This file might have been installed via the python-pkg-resources package. Therefore updating or reinstalling this package will reinstate the stale module! Also be aware that you're messing with a file which is supposed to be controlled by apt.