Are you having trouble solving the error 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 stating “modulenotfounderror: no module named 'distutils.msvccompiler'
.” This error indicates that the Microsoft Visual C++ Compiler module
from the distutils package
is not found on your system or Python environment.
What is Python?
Python is one of the most popular programming languages. It is used for developing a wide range of applications. It is a high-level programming language that is usually used by developers nowadays 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
Here’s how to resolve the error message stating modulenotfounderror: no module named 'distutils.msvccompiler'
in Python.
- Download and install Visual C++.
Resolving the errormodulenotfounderror: 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. - 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 commandpip install --upgrade setuptools
.
The commandpip 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. - Install the msvc-runtime package.
To install the msvc-runtime package, use the commandpip install msvc-runtime
.
The commandpip 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
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 instead ofpip list
. However, if you’re using Anaconda, use the commandconda list
.
python -m
Include this command in yourpip 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 commandpython3 -m pip install msvc-runtime
instead ofpython -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
instead ofpip show msvc-runtime
.
Note: You can use the commandpip 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
instead ofpip 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 or Python environment.
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. If you have any questions or suggestions, please leave a comment below, and for more Python tutorials, visit our website.
Thank you for reading!