What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Install Matplotlib in the same Python environment that runs your script, notebook, or IDE session. For a pip-managed environment, run python -m pip install -U matplotlib with that environment’s Python, then verify the import from the same context. If installation appears successful but the error remains, the usual issue is that installation and execution are using different interpreters.
Install Matplotlib in the Python environment that runs your code
The package is named matplotlib; a common plotting import is import matplotlib.pyplot as plt. A ModuleNotFoundError means the interpreter running the code cannot find that package on its import path. Matplotlib’s guide recommends checking which Python binary is active when an import fails.
Choose the command that matches the environment manager used by the project. Matplotlib’s current stable installation guide lists these options:
| Environment manager | Install command | Use when |
|---|---|---|
| pip | python -m pip install -U matplotlib |
The selected Python environment is managed with pip. The -U option requests an upgrade to the official release. |
| conda | conda install -c conda-forge matplotlib |
The project runs in a conda environment; activate or select the matching environment first. |
| pixi | pixi add matplotlib |
The project is managed with pixi. |
| uv | uv add matplotlib |
The project is managed with uv. |
These commands and package-manager choices are listed in the Matplotlib installation guide. If you use pip and want the documented upgrade sequence, first run python -m pip install -U pip, then python -m pip install -U matplotlib.
#1 Best Overall
Check that the right interpreter is selected
Installing with one Python does not make the package available to every other Python on the computer. This commonly happens when a system Python, virtual environment, conda environment, notebook kernel, and IDE each point to different interpreters.
- Identify the interpreter that runs the failing code. On macOS or Linux,
which python3shows the executable found aspython3in the current terminal. In Windows, check the interpreter selected by the shell or IDE you use. For an IDE or notebook, confirm its configured interpreter or kernel rather than relying on a separate terminal. - Install through that interpreter. For a pip-managed environment, run
python -m pip install matplotlibusing the executable that launches the program. If the project uses a virtual environment, activate it first. With conda, select the environment that runs the project and install into that environment. - Verify from the same context. Run the check below in the terminal, notebook kernel, or IDE interpreter that needs Matplotlib. An import that succeeds in a different shell is not proof that the failing context can import it.
Matplotlib’s troubleshooting guidance also recommends checking the Python binary when import fails. The python -m pip form helps keep pip associated with the Python executable named in the command.
Rank #2
Verify the installation and locate the imported package
Run this with the same interpreter that executes your code:
python -c "import matplotlib; print(matplotlib.__version__, matplotlib.__file__)"
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallIf successful, the output includes the installed version and the path from which Python loaded Matplotlib. The path is useful if multiple environments or copies exist. Matplotlib documents this import-and-location check in its installation and troubleshooting guide.
If the error continues after installation
Compare the install and run environments
Run the verification command in the exact context where the exception occurs. If it fails there but succeeds in another terminal, the two contexts are using different interpreters or environments. Select the project’s interpreter or kernel, then install Matplotlib through that environment’s manager.
Check import paths only after confirming the interpreter
PYTHONPATH adds directories to Python’s module search list, so an unusual value can affect what Python finds. It is not the first setting to change: first confirm that the failing program uses the interpreter where Matplotlib was installed. MPLCONFIGDIR has a different purpose—it sets Matplotlib’s configuration and cache location and is not the usual remedy for a missing import. See Matplotlib’s environment-variable reference.
Use the package source appropriate to the Python distribution
On Debian or Ubuntu, Fedora, Red Hat, and Arch, Matplotlib’s guide lists operating-system package examples: sudo apt-get install python3-matplotlib, sudo dnf install python3-matplotlib, sudo yum install python3-matplotlib, and sudo pacman -S python-matplotlib, respectively. Choose a route consistent with the Python distribution and environment running your code; an OS package may not belong to a separate virtual environment.
Best Value
For pip, Matplotlib provides wheels for macOS, Windows, and Linux. If pip attempts a source build and compilation fails, the guide says --prefer-binary can select the newest release with a precompiled wheel available for the operating system and Python. Its listed command for the official release is python -m pip install -U matplotlib.
When Matplotlib imports but no plot window appears
A missing-module error and a plot that does not display are separate problems. If import matplotlib succeeds, investigate the plotting backend and GUI dependencies rather than reinstalling the package to fix an import failure. Matplotlib’s installation guide notes that TkAgg requires Tk bindings. It also warns that uv’s Python builds from python-build-standalone need to be recent for TkAgg window display, recommending uv 0.8.7 or newer and upgrading the bundled Python. Those notes concern window display, not whether Matplotlib can be imported.
Matplotlib says mandatory dependencies should be installed automatically when the package is installed through a manager such as pip or conda; its dependency list is primarily for reference and troubleshooting. Consult the installation guide for platform- and backend-specific details.
Quick Recap
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.




