Last updated: Apr 10, 2024
Reading timeยท2 min
The error "ModuleNotFoundError: No module named 'distutils.util'" occurs when
your Ubuntu machine doesn't have the distutils
module installed.
To solve the error, run the sudo apt-get install python3-distutils
command
to install the distutils
module.
The three common errors that are caused by not having the distutils
module
installed alongside Python are:
distutils
module.Open your terminal and run the following commands.
sudo apt update sudo apt install python3-distutils sudo apt install python3-apt # ๐๏ธ For Python 3.10 (scoped to specific version) sudo apt install python3.10-distutils # ๐๏ธ For Python 3.11 sudo apt install python3.11-distutils
The distutils
module is a part of the Python standard library so it has to be
installed on your Ubuntu machine to be able to use Python.
If you get the "ModuleNotFoundError: No module named 'pip'", check out my other article with instructions on how to install pip.
If the error is not resolved, try reinstalling the distutils
package.
sudo apt-get install --reinstall python3-distutils # ๐๏ธ For Python 3.10 sudo apt-get install --reinstall python3.10-distutils # ๐๏ธ For Python 3.11 sudo apt-get install --reinstall python3.11-distutils
If that didn't help, add the deadsnakes
PPA and install a specific version of
distutils
.
You can view your Python version by issuing the python --version
command.
python --version
For example, my Python version is 3.10.4
, so I have to issue the
sudo apt-get install python3.10-distutils
command.
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update sudo apt-get install python3.10-distutils sudo apt-get install python3.10-apt
3.9.X
, you would issue the sudo apt-get install python3.9-distutils
command.If the suggestion didn't help try reinstalling the distutils
package scoped to
your specific Python version.
sudo apt-get install --reinstall python3.10-distutils
Make sure to update the version in the command according to the output of the
python --version
command.
If you get any errors related to pip
, install pip by following the
instructions in my
ModuleNotFoundError: No module named 'pip' in Python
article.