[Fix ✔️] ModuleNotFoundError: No module named ‘distutils.cmd’

ModuleNotFoundError: No module named 'distutils.cmd'

I got this error today with AWS SAM: ModuleNotFoundError: No module named ‘distutils.cmd’, here is how I fixed it.

sudo apt-get install python3.9-distutils

Keep reading below for more details.

Quick Fix for ModuleNotFoundError: No module named ‘distutils.cmd’

The issue for me was pip, which comes with distutils, wasn’t installed for python 3.9, which is what AWS SAM was trying to use. The fix is to make sure distutils is installed for python 3.9.

You can verify this is your issues by checking for pip with the specific Python version you are using:

python3.9 -m pip --version 

Running the above command threw the same error about distutils.cmd

Ubuntu / Debian fix:

Install distutils for python3.9

sudo apt-get install python3.9-distutils

Sources

https://github.com/pypa/get-pip/issues/124

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.