The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
If Python raises ModuleNotFoundError after pip install, first make sure the command installing the package and the process running your code use the same Python interpreter and environment. Then verify that you are importing the package’s documented module name, not necessarily its distribution name. If those match, inspect the failing process’s sys.path to see where Python is searching.
1. Check which Python installed the package
pip can install a package for one Python interpreter while your script runs under another. The pip User Guide explains that “python -m pip executes pip using the Python interpreter you specified as python.” Use the same interpreter command for installation and for launching your program.
In the shell or environment you use to start the failing code, run:
python -c "import sys; print(sys.executable)"
python -m pip --version
python -m pip show package-name
Replace package-name with the name used in your install command. The first command prints the interpreter’s executable path; the others show which pip is attached to it and whether that interpreter can see the distribution. If python is not the command that runs your script, use the matching one instead. For example, Python’s installation guide shows version-qualified forms such as python3.12 -m pip and, on Windows, py -3.x -m pip. See the Python Packaging User Guide.
#1 Best Overall
If pip show cannot find the package for the interpreter you intend to use, install it through that interpreter:
python -m pip install package-name
Use the same version-qualified command for both installation and execution if your system has multiple Python versions.
Rank #2
2. Match the virtual environment, notebook, or IDE
A virtual environment has its own interpreter and package locations. Activate the project’s intended environment before installing and running the code, or invoke that environment’s Python executable directly. Python’s path initialization documentation describes how pyvenv.cfg affects a virtual environment’s prefix; the Python Packaging User Guide explains installing packages into an active environment.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsA terminal install does not establish that a notebook kernel, IDE, service, or scheduled job uses that same environment. Print sys.executable from inside the failing process and compare its path with the interpreter used for installation. In a notebook, run this in a cell:
import sys
print(sys.executable)
If the paths differ, switch the application or notebook to the intended interpreter, or install the package using the interpreter the application actually runs.
3. Confirm the package’s import name
The name supplied to pip install identifies a distribution. Your code imports a module or package provided by that distribution, and those names are not guaranteed to match. Check the project’s official usage instructions for the correct import statement rather than guessing from spelling, punctuation, capitalization, or singular and plural forms.
4. Inspect the failing process’s search path
Python resolves imports by searching the module locations in sys.path. From the process that raises the error, print its interpreter, environment prefix, and search path:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
import sys
print(sys.executable)
print(sys.prefix)
print(sys.path)
Python initializes this path when the interpreter starts, and site processing adds package directories. The details can depend on the Python version and startup configuration; see the path initialization documentation and the site documentation.
Best Value
If the expected package location is missing from sys.path, check which interpreter launched the process and whether startup options or configuration changed path initialization. Avoid making a permanent PYTHONPATH change your first fix: Python’s documentation notes that it affects all installed Python versions and environments.
5. Check whether installation or import failed in a different way
Read the complete installation output. If the install command reported an error, that command’s failure does not show that the package was installed. If the import starts but raises a different exception, use that traceback to diagnose the new failure instead of repeatedly reinstalling the package. A package-specific runtime error needs a diagnosis based on its own traceback.
Quick Recap
Use this order to narrow down the mismatch
- Interpreter: Compare the executable used to install the package with the one running the failing code.
- Environment: Confirm the terminal, virtual environment, notebook kernel, IDE, or service is using the intended environment.
- Name: Check the package’s documented import name against the name used in your
importstatement. - Search path: Inspect
sys.pathin the failing process and check whether it includes the package’s location.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.
Recommended Free Tools

