how to install python distutils

PythonDistutils

Python Problem Overview


I just got some space on a VPS server(running on ubuntu 8.04), and I'm trying to install django on it. The server has python 2.5 installed, but I guess its non standard installation. When I run install script for django, I get

amitoj@ninja:~/Django-1.2.1$ python setup.py install
Traceback (most recent call last):
  File "setup.py", line 1, in <module>
    from distutils.core import setup
ImportError: No module named distutils.core

I'm stumped. All the articles on internet tell me how to install modules using distutils. But how do I get distutils itself? Can anyone point me to the archive for distutils? I looked in /usr/lib/local/python2.5, /usr/lib/python2.5 etc, and as expected there is no distutils to be found.

Python Solutions


Solution 1 - Python

I know this is an old question, but I just come across the same issue using Python 3.6 in Ubuntu, and I am able to solve it using the following command:

sudo apt-get install python3-distutils

Solution 2 - Python

If you are unable to install with either of these:

sudo apt-get install python-distutils
sudo apt-get install python3-distutils

Try this instead:

sudo apt-get install python-distutils-extra

Ref: https://groups.google.com/forum/#!topic/beagleboard/RDlTq8sMxro

Solution 3 - Python

you can use sudo apt-get install python3-distutils by root permission.

i believe it worked here

Solution 4 - Python

You can install the python-distutils package. sudo apt-get install python-distutils should suffice.

Solution 5 - Python

I ran across this error on a Beaglebone Black using the standard Angstrom distribution. It is currently running Python 2.7.3, but does not include distutils. The solution for me was to install distutils. (It required su privileges.)

    su
    opkg install python-distutils

After that installation, the previously erroring command ran fine.

    python setup.py build

Solution 6 - Python

The simplest way to install setuptools when it isn't already there and you can't use a package manager is to download ez_setup.py and run it with the appropriate Python interpreter. This works even if you have multiple versions of Python around: just run ez_setup.py once with each Python.

Edit: note that recent versions of Python 3 include setuptools in the distribution so you no longer need to install separately. The script mentioned here is only relevant for old versions of Python.

Solution 7 - Python

The module not found likely means the packages aren't installed.

Debian has decided that distutils is not a core python package, so it is not included in the last versions of debian and debian-based OSes. You should be able to do

sudo apt-get install python3-distutils
sudo apt-get install python3-apt

Solution 8 - Python

If you are in a scenario where you are using one of the latest versions of Ubuntu (or variants like Linux Mint), one which comes with Python 3.8, then you will NOT be able to have Python3.7 distutils, alias not be able to use pip or pipenv with Python 3.7, see: https://stackoverflow.com/questions/61567990/how-to-install-python-distutils-for-old-python-versions

Obviously using Python3.8 is no problem.

Solution 9 - Python

If the system Python is borked (i.e. the OS packages split distutils in a python-devel package) and you can’t ask a sysadmin to install the missing piece, then you’ll have to install your own Python. It requires some header files and a compiler toolchain. If you can’t have those, try compiling a Python on an identical computer and just copying it.

Solution 10 - Python

By searching all python-distutils related package:

apt-cache search x

I get python3-distutils-extra - enhancements to the Python3 build system

Then just try:

sudo apt-get install python3-distutils-extra

Solution 11 - Python

This didn't work for me: sudo apt-get install python-distutils

So, I tried this: sudo apt-get install python3-distutils

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNeoView Question on Stackoverflow
Solution 1 - PythonettananyView Answer on Stackoverflow
Solution 2 - PythonBen AmosView Answer on Stackoverflow
Solution 3 - PythonMohammad HeydariView Answer on Stackoverflow
Solution 4 - PythonManoj GovindanView Answer on Stackoverflow
Solution 5 - PythonmightypileView Answer on Stackoverflow
Solution 6 - PythonDuncanView Answer on Stackoverflow
Solution 7 - PythonAbdul BasitView Answer on Stackoverflow
Solution 8 - PythonZoltan FedorView Answer on Stackoverflow
Solution 9 - PythonmerwokView Answer on Stackoverflow
Solution 10 - PythonFrances HeView Answer on Stackoverflow
Solution 11 - PythonCyebukayireView Answer on Stackoverflow