I encounter "No module named DistUtilsExtra.command" when trying to install

Asked by Andreas Damgaard Pedersen

I'm trying to import this python library. When I run the command `pip install python-apt` I get the following error

Collecting python-apt
  Using cached python-apt-0.7.8.tar.bz2
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-G7jXb2/python-apt/setup.py", line 6, in <module>
        from DistUtilsExtra.command import *
    ImportError: No module named DistUtilsExtra.command

Googling around on the internet suggested that the few that had a similar problem solved it by installing `python-distutils-extra`. However I already have this module installed. I'm using python 2.7 and Ubuntu 14.04.

(virtualenv)me@desktop:~/Projects/letsgo$ sudo apt-get install python-setuptools python-distutils-extra
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-distutils-extra is already the newest version.
python-setuptools is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 7 not upgraded.

Question information

Language:
English Edit question
Status:
Expired
For:
Ubuntu python-apt Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

What is the output of;

lsb_release -a; uname -a

Thanks

Revision history for this message
Andreas Damgaard Pedersen (andreas-damgaard-p) said :
#2

LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:cxx-3.0-amd64:cxx-3.0-noarch:cxx-3.1-amd64:cxx-3.1-noarch:cxx-3.2-amd64:cxx-3.2-noarch:cxx-4.0-amd64:cxx-4.0-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-3.1-amd64:desktop-3.1-noarch:desktop-3.2-amd64:desktop-3.2-noarch:desktop-4.0-amd64:desktop-4.0-noarch:desktop-4.1-amd64:desktop-4.1-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.0-amd64:graphics-3.0-noarch:graphics-3.1-amd64:graphics-3.1-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch:graphics-4.1-amd64:graphics-4.1-noarch:languages-3.2-amd64:languages-3.2-noarch:languages-4.0-amd64:languages-4.0-noarch:languages-4.1-amd64:languages-4.1-noarch:multimedia-3.2-amd64:multimedia-3.2-noarch:multimedia-4.0-amd64:multimedia-4.0-noarch:multimedia-4.1-amd64:multimedia-4.1-noarch:printing-3.2-amd64:printing-3.2-noarch:printing-4.0-amd64:printing-4.0-noarch:printing-4.1-amd64:printing-4.1-noarch:qt4-3.1-amd64:qt4-3.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
Linux ubuntu 3.16.0-55-generic #74~14.04.1-Ubuntu SMP Tue Nov 17 10:15:59 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

Revision history for this message
Manfred Hampl (m-hampl) said :
#3

Why are you trying to install python-apt with pip?
The recommended installation is using the pre-built Ubuntu packages and installing them with software-center or apt-get.

What do you get for the command
sudo apt-get install python-apt

Revision history for this message
Launchpad Janitor (janitor) said :
#4

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.

Revision history for this message
Reece (reece) said :
#5
Revision history for this message
Manfred Hampl (m-hampl) said :
#6

python-apt version 0.7.8 is a very old and obsolete version (was for Ubuntu 9.04).
For Ubuntu 14.04 the designated version is 1.1.0 (1.1.0~beta1build1)
I suggest that you try with the new version or use the standard package management tools as provided by Ubuntu.

Revision history for this message
Manfred Hampl (m-hampl) said :
#7

Sorry, I mixed the versions.
For 14.04 the version should be 0.9.3.5ubuntu2
version 1.1.0 is for the 16.04 release.

Nevertheless my conclusion "use the correct version for your release" stays the same.

Also installing python-distutils-extra might help.

Revision history for this message
Giuseppe Attardi (giuseppe.attardi) said :
#8

I have the same problem when calling:

   tox -e pep8

which in turn invokes:

    ~/.tox/pep8/bin/pip install python-apt -r~/requirements.txt -r~/test-requirements.txt

As it turns out, the script installed by tox as:

   ~/.tox/pep8/bin/pip

starts with:

   #!~/.tox/pep8/bin/python2.7

instead of

   #!/usr/bin/python

By replacing that line, the script works.
Unfortunately, each invocation of too generates that script again, with reference to the wrong executable.

Revision history for this message
Manfred Hampl (m-hampl) said :
#9

@Giuseppe:
Please do not misuse old expired questions for your own problem, but create a question document of your own.
Your problem seems to be different (probably related to tox, not python-apt or pip).