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


Just noticed it's won't overwrite the OS version of setuptools:

Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.1.2-py2.py3-none-any.whl#md5=5ff9fec0be479e4e36df467556deed4d
  Downloading pip-7.1.2-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Downloading/unpacking setuptools from https://pypi.python.org/packages/3.4/s/setuptools/setuptools-18.3.2-py2.py3-none-any.whl#md5=58c1e15fe0c124ab0880a2691f232434
  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...


  • 1
    sudo pip install -U pip setuptools
    – A.B.
    Oct 9 '15 at 21:37
  • @A.B Just tried this and noticed it won't overwrite the O.S. version ... this is probably the problem.. Oct 10 '15 at 6:04
  1. Remove the repository version

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

    wget https://bootstrap.pypa.io/get-pip.py
    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


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:

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

    $ python -c 'import pkg_resources; print(pkg_resources.__file__)'
  2. Remove this file and its .py file:

    $ sudo rm /usr/lib/python2.7/dist-packages/pkg_resources.py*


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
    I accepted the A.B. answer as it was most of the way there, but if I could accept both I would. - I haven't had a chance to try this yet, as I have since upgraded Ubuntu and am a little leery about messing with setuptools on it, I'll probably need to try this in a virtual machine to see what happens. Nov 27 '15 at 4:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.