ImportError: No module named distutils

setevoy picture setevoy · May 13, 2014 · Viewed 17.9k times · Source

Attempt to install psutils resulted a big headache...

$ python -V
Python 2.4.2

$ cat /etc/SuSE-release
SUSE Linux Enterprise Server 10 (x86_64)
VERSION = 10
PATCHLEVEL = 4


$ cd psutil-2.1.1/
$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 17, in ?
    from distutils.core import setup, Extension
ImportError: No module named distutils.core

Next - I try to install setuptools to use easy_install:

$ which easy_install
which: no easy_install

$ cd ../setuptools-1.4/

$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 12, in ?
    from distutils.util import convert_path
ImportError: No module named distutils.util

Trying install distutils from ez_setup.py:

$ python ez_setup.py
Traceback (most recent call last):
  File "ez_setup.py", line 278, in ?
    main(sys.argv[1:])
  File "ez_setup.py", line 210, in main
    egg = download_setuptools(version, delay=0)
  File "ez_setup.py", line 139, in download_setuptools
    from distutils import log
ImportError: No module named distutils

So - how can I install it?

P.S. No, I haven't root on this machine and can't use package manager.

Answer

steveoams picture steveoams · Jun 27, 2019

you need to run this (if Error happens on python3) ==> sudo apt-get install python3-distutils --reinstall

you need to run this (if Error happens on python2) ==> sudo apt-get install python2-distutils --reinstall