Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

how to upgrade python setuptools > 12.2 on ubuntu 15.04

Writer 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]

2

2 Answers

  1. Remove the repository version

    sudo apt-get remove python-setuptools
  2. If necessary, install pip again

    wget
    sudo -H python get-pip.py
  3. Install setuptools via pip

    sudo -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.2

Note

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!

1

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:

  1. Find out where the outdated pkg_resources module is located:

    $ python -c 'import pkg_resources; print(pkg_resources.__file__)'
    /usr/lib/python2.7/dist-packages/pkg_resources.pyc
  2. Remove this file and its .py file:

    $ 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.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy