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.
- 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.
- 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:

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.
- Install the msvc-runtime package.
To install the msvc-runtime package, use the command:
pip install msvc-runtime
Example:

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 setuptoolsInstalling 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-runtimeSee 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!
Related Python Tutorials
- Modulenotfounderror No Module Named Serial
- Modulenotfounderror No Module Named Attrdict Solved
- Modulenotfounderror No Module Named Pyodbc Solved
- Modulenotfounderror No Module Named Mlxtend Solved
- Modulenotfounderror No Module Named Flask Ext
- Modulenotfounderror No Module Named Tensorboardx Solved
Root causes of Modulenotfounderror: no module named ‘distutils.msvccompiler’
- Package not installed. The module you’re importing was never installed in the current environment. Fix: pip install <package-name>.
- Wrong virtual environment active. You installed in one venv but running from a different environment. Verify with which python and which pip.
- Multiple Python versions. pip installs for one Python, but you’re running a different version. Use python -m pip install <package> to force it.
- Typo in module name. Case-sensitive imports. Beautiful_Soup vs beautifulsoup4 vs bs4. Check the actual import name in the package docs.
- Package uninstalled or corrupted. Try pip install –force-reinstall <package> to freshen the install.
Step-by-step debugging
- Verify Python path. import sys; print(sys.executable) shows which Python is running.
- Check installed packages. pip list | grep <package> confirms it’s actually installed.
- Match environment. Confirm the terminal that ran pip install is the same environment your code runs in.
- Reinstall cleanly. pip uninstall <package> then pip install <package>.
- Try python -m install. python -m pip install <package> avoids PATH mismatches.
Working install pattern
# Create fresh environment (recommended for any new project) python -m venv myenv source myenv/bin/activate # Windows: myenv\Scripts\activate # Install requirements pip install --upgrade pip pip install <package-you-need> # Verify install pip list | grep <package> python -c "import <package>; print(<package>.__version__)"
When the error persists
- Check for typos. Module names can differ from PyPI names (opencv-python vs cv2, beautifulsoup4 vs bs4).
- Update Python or downgrade the package. Some packages have version-specific compatibility.
- Restart the interpreter or kernel. Jupyter and IDEs cache import state.
- Check for conda/pip conflicts. If using Anaconda, prefer conda install <package> over pip.
