Modulenotfounderror: no module named ‘distutils.msvccompiler’

Are you having trouble solving the modulenotfounderror: no module named ‘distutils.msvccompiler’ in Python?

This error may sound complicated, but don’t worry; we will help you solve it.

In this article, we will show you the solution to the error message mentioned above.

The error above indicates that the Microsoft Visual C++ Compiler module from the distutils package is not found on your system.

What is Python?

Python is one of the most popular programming languages.

It is used for developing a wide range of applications.

In addition, Python is a high-level programming language that is used by most developers due to its flexibility.

Returning to our issue, we must take a few actions to fix this error.

So, without further ado, let’s move on to our “how to fix this error” tutorial.

How to solve “no module named ‘distutils.msvccompiler’” in Python

Time needed: 1 minute

Here’s how to resolve the modulenotfounderror: no module named ‘distutils.msvccompiler’ in Python.

  1. Download and install Visual C++.


    Resolving the error modulenotfounderror: no module named ‘distutils.msvccompiler’ is an easy task.

    All you have to do is download and install the Microsoft Visual C++ Build Tools, then upgrade the setuptools.

    To download and install Visual C++, go to the official Microsoft website.

  2. Upgrade your setuptools.


    The next thing you should do is upgrade your setup tools.

    To upgrade this, open your cmd or command prompt, then input the command:

    pip install –upgrade setuptools

    Example:

    pip install --upgrade setuptools - Modulenotfounderror: no module named 'distutils.msvccompiler'

    The command pip install –upgrade setuptools will upgrade the ‘setuptools’ module on your system.

    Note: If the error still exists after doing the steps above, do the step below.

  3. Install the msvc-runtime package.


    To install the msvc-runtime package, use the command:

    pip install msvc-runtime

    Example:

    pip install msvc-runtime - Modulenotfounderror: no module named 'distutils.msvccompiler'

    The command pip install msvc-runtime will install the msvc-runtime package on your system.

Upgrading the ‘setuptools’ on the Jupyter notebook

The command below will allow you to upgrade the installed setuptools on your system if you’re using Jupyter Notebook.

!pip install --upgrade setuptools

Installing the msvc-runtime package on a Jupyter notebook

The command below will allow you to install the msvc-runtime package on your system if you’re using Jupyter Notebook.

!pip install msvc-runtime

See also: Modulenotfounderror: no module named ‘attrdict’

Commands you might need

  • pip list

    This command will display all the packages installed on your system, including their versions.

    If you’re using Jupyter Notebook, use the !pip list command.

    However, if you’re using Anaconda, use the command conda list.
  • python -m

    Include this command in your pip install msvc-runtime command if you get an error message stating that “pip” cannot be found.

    Example: python -m pip install msvc-runtime

    However, if you’re using Python 3, use the command python3 -m pip install msvc-runtime.
  • pip install –upgrade pip

    Use this command to upgrade the pip package manager to its newest version.

    If your pip is already in the latest version, this will come out: “Requirement already satisfied.”
  • python –version

    Use this command if you want to check what version of Python you have.
  • pip show msvc-runtime

    Use this command to display information about your msvc-runtime package, including its location.

    If you’re using Jupyter Notebook, use the command !pip show msvc-runtime.

    Note: You can use the command pip show to display the information of the module or package installed in your system.
  • pip install –upgrade msvc-runtime

    Use this command to upgrade your msvc-runtime package to its latest version.

    If it is already the latest version, this will come out: “Requirement already satisfied.”

    If you’re using Jupyter Notebook, use the command !pip install –upgrade msvc-runtime.

Conclusion

In conclusion, the error modulenotfounderror: no module named ‘distutils.msvccompiler’ can be easily solved by downloading and installing the Microsoft Visual C++ Build Tools in your system.

By following the guide above, there’s no doubt that you’ll be able to resolve this error quickly.

We hope you’ve learned a lot from this.

Thank you for reading!

Leave a Comment