pip of python installed via deadsnakes, shows "no module named distutils" error

93 views Asked by At

When installing python using deadsnakes ppa, and using pip on it like in the following example

python3.12 -m pip install django

will result in the following error

  File "/usr/lib/python3/dist-packages/pip/_internal/locations/_distutils.py", line 9, in <module>
    from distutils.cmd import Command as DistutilsCommand
ModuleNotFoundError: No module named 'distutils'
1

There are 1 answers

2
CodeDude On BEST ANSWER

Short answer

Run

sudo apt install python3.12-distutils

and this should solve your problem InshaAllah

Long Answer

When installing any python version using the deadsnakes ppa, you won't install an important package called distutils which is required for pip to run, if you have any other version other than python3.12, than use the following format

sudo apt install python{version}-distutils