1

I got the following ImportError as i tried to setup.py install a package:

Traceback (most recent call last):
   File "setup.py", line 4, in <module>
    from setuptools import setup, Extension
ImportError: No module named setuptools

This happens although setuptools is already installed:

amir@amir-debian:~$ sudo apt-get install python-setuptools
[sudo] password for amir: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-setuptools is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Why can't python find the setuptools module?

  • Possible duplicate of [Python 3: ImportError "No Module named Setuptools"](https://stackoverflow.com/questions/14426491/python-3-importerror-no-module-named-setuptools) – IzPrEE Oct 28 '19 at 20:59

1 Answers1

1

It's possible you have multiple python versions installed on your system. For example if you installed your python from source, and then again with apt-get. Apt-get will install to the default python version. Make sure you are being consistent.

Potentially using pip install setuptools could solve your problem.

Try these commands:

$which python
/usr/bin/python
$python --version
Python 2.7.12

Making sure that the output matches your expectations.

It may be worth removing previous installations and starting over as this answer suggests:

Python 3: ImportError "No Module named Setuptools"

Community
  • 1
  • 1
IzPrEE
  • 153
  • 1
  • 12
  • I have recently installed python2.7.12 from source. Should i point it to the dist-packages of the old versions on my system (2.7.3)? How can i be consistent? –  Oct 07 '16 at 23:01
  • Apt-get is a package manager for debian. Presumably if you you had installed python via 'apt-get install python' it would have worked. Your best bet is to use the python package manager that comes installed on versions greater than 2.7.9 which is called 'pip'. The command being: pip install setuptools – IzPrEE Oct 07 '16 at 23:07
  • I have tried pip, but setuptools is already newset version: `Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/dist-packages` –  Oct 07 '16 at 23:09