close

[Solved] ModuleNotFoundError: No module named ‘distutils.core’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ModuleNotFoundError: No module named ‘distutils.core’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ModuleNotFoundError: No module named ‘distutils.core’ Error Occurs?

Today I get the following error ModuleNotFoundError: No module named ‘distutils.core’ in python.

How To Solve ModuleNotFoundError: No module named ‘distutils.core’ Error ?

  1. How To Solve ModuleNotFoundError: No module named 'distutils.core' Error ?

    To Solve ModuleNotFoundError: No module named 'distutils.core' Error Python base interpreter does require some additional modules. Those are not installed with e.g. Ubuntu 18.04 as default.

  2. ModuleNotFoundError: No module named 'distutils.core'

    To Solve ModuleNotFoundError: No module named 'distutils.core' Error Python base interpreter does require some additional modules. Those are not installed with e.g. Ubuntu 18.04 as default.

Solution 1

Python base interpreter does require some additional modules. Those are not installed with e.g. Ubuntu 18.04 as default.

To solve this we need to first find the python version you’re running. If you have only installed one python version on your system (and you are sure about it) you can skip this step.

# from your project interpreter run
# your_project_python --version
$ python3 --version
Python 3.7.8

You now need to install for this precise python interpreter the distutils. So here the solution for this example would be:

sudo apt install python3.7-distutils
# sudo apt install python3-distutils  # would just update default python intrpreter

Keep in mind, that just running python from any command line might be an other version of python then you’re running in your project!

If this hasn’t helped, look for the following possibilities. This will bring you the binary which resolved from the alias in the command line.

$ which python
/usr/bin/python
$ ls -lach /usr/bin/python
lrwxrwxrwx 1 root root 9 Jun  8  2018 /usr/bin/python -> python2.7

original source: refer to this article

For this answer I’ve also merged, summarized, ordered and explained some of the content which has been provided by Neo, Andrei, Mostafa and Wolfgang.

As a side note for sorcerer’s apprentice: You might be tempted to uninstall python interpreters. For proposed solution not necessary at all!! How ever, keep in mind that there is one python interpreter which your whole OS depends on. So this default one, you don’t want to uninstall. If you do so, you’re in a certain mess in finding your desktop taskbar and basically everything.

Solution 2

If I have multiple versions of python3 (etc 3.8 as main and 3.9 from ppa:deadsnakes/ppa) on ubuntu 20.04 (in my case kubuntu 20.04) and it doesn’t work

sudo apt install python3-distutils

then it works for me

sudo apt install python3.9-distutils

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read