Whether your code is throwing compatibility warnings, a newer Matplotlib version has features you want to use, or you just need a clean slate, this guide covers everything.
I’ll show you how to check your current version, upgrade Matplotlib, install a specific version, and completely uninstall it — using pip, conda, and inside virtual environments.
Check Your Current Matplotlib Version First
Before doing anything else, check what version you’re running. Open your terminal and run:
python -m pip show matplotlib
I executed the above example code and added the screenshot below.

This gives you a full picture — the version number, install location, and its dependencies:
Name: matplotlib
Version: 3.8.2
Summary: Python plotting package
Location: /usr/local/lib/python3.12/site-packages
Requires: contourpy, cycler, fonttools, kiwisolver, numpy, packaging, pillow, pyparsing, python-dateutil
Or if you just want the version number quickly:
python -c "import matplotlib; print(matplotlib.__version__)"
You can also check it from inside a Python shell or Jupyter Notebook:
import matplotlib
print(matplotlib.__version__)
Check the Latest Available Version Before Upgrading
Before upgrading, it’s worth checking what the latest stable version of Matplotlib is on PyPI:
pip index versions matplotlib
This lists all available versions from newest to oldest. If you want just the latest version number without upgrading:
pip install matplotlib==
Leave the version number blank and pip will return an error message that helpfully shows you all available versions — a quick hack that works.
How to Upgrade Matplotlib Using pip
Let’s see how to upgrade Matplotlib using pip.
Upgrade to the Latest Stable Version
This is the command you’ll use most of the time:
python -m pip install --upgrade matplotlib
Again, I use python -m pip instead of just pip to make sure I’m upgrading inside the correct Python environment — especially important when you have multiple Python versions installed.
After upgrading, verify the new version:
python -c "import matplotlib; print(matplotlib.__version__)"
I executed the above example code and added the screenshot below.

Upgrade pip Itself Before Upgrading Matplotlib
If you haven’t updated pip in a while, it’s good practice to upgrade it first. An outdated pip can sometimes cause installation issues:
python -m pip install --upgrade pip
python -m pip install --upgrade matplotlib
Read: Matplotlib Plots a Line
Upgrade Matplotlib and All Its Dependencies at Once
Matplotlib depends on several packages — NumPy, Pillow, contourpy, and others. To upgrade everything together:
python -m pip install --upgrade matplotlib numpy pillow
How to Install a Specific Version of Matplotlib
Sometimes you don’t want the latest version. Maybe you’re working on a project that requires a specific Matplotlib version for compatibility reasons, or you’re following a tutorial written for an older version.
To install a specific version:
pip install matplotlib==3.8.0
Replace 3.8.0 with whichever version you need.
To install a version within a range (at least 3.7 but less than 3.9):
pip install "matplotlib>=3.7,<3.9"
To install the minimum version or higher:
pip install "matplotlib>=3.8"
Downgrade Matplotlib to an Older Version
If you just upgraded and something broke, you can roll back to the previous version:
pip install matplotlib==3.8.2
pip will uninstall the current version and install the one you specify.
Check out: Python Plot Multiple Lines Using Matplotlib
How to Upgrade Matplotlib in a Virtual Environment
If you’re using a virtual environment (and you should be for any real project), activate it first and then upgrade:
On macOS/Linux:
source venv/bin/activate
pip install --upgrade matplotlib
On Windows:
venv\Scripts\activate
pip install --upgrade matplotlib
The upgrade only affects packages inside the active environment — nothing else on your machine is touched. That’s exactly the point of virtual environments.
How to Upgrade Matplotlib With Conda
If you’re using Anaconda or Miniconda, use conda to upgrade — not pip — so conda can properly manage all dependencies:
conda update matplotlib
To upgrade to the absolute latest version available on conda-forge:
conda update -c conda-forge matplotlib
To upgrade everything in your conda environment at once (use with care):
conda update --all
Check the new version after upgrading:
python -c "import matplotlib; print(matplotlib.__version__)"
How to Uninstall Matplotlib Using pip
Here, we will learn how to uninstall Matplotlib using pip
Basic Uninstall
pip uninstall matplotlib
I executed the above example code and added the screenshot below.

pip will ask you to confirm:
Found existing installation: matplotlib 3.10.1
Uninstalling matplotlib-3.10.1:
Would remove:
/usr/local/lib/python3.12/site-packages/matplotlib/*
/usr/local/lib/python3.12/site-packages/mpl_toolkits/*
/usr/local/lib/python3.12/site-packages/pylab.py
Proceed (Y/n)?
Type Y and press Enter. Done.
Skip the Confirmation Prompt
If you’re scripting this or just want a faster uninstall:
pip uninstall matplotlib -y
The -y flag auto-confirms without prompting.
Uninstall With Verbose Output
If you want to see exactly what’s being removed:
pip uninstall matplotlib --verbose
Read: What is Matplotlib Inline in Python
How to Completely Remove Matplotlib (Clean Uninstall)
A regular pip uninstall removes the package files, but Matplotlib also stores cached data — fonts, style files, configuration — in a separate folder. If you’re doing a clean reinstall to fix a broken installation, you need to clear those too.
Step 1: Uninstall the package
pip uninstall matplotlib -y
Step 2: Clear the pip cache
pip cache purge
Step 3: Delete the Matplotlib config/cache folder
This is where Matplotlib stores its font cache, style sheets, and configuration files. The location depends on your OS:
On macOS/Linux:
rm -rf ~/.config/matplotlib
rm -rf ~/.cache/matplotlib
On Windows (in Command Prompt):
rmdir /s /q %USERPROFILE%\.matplotlib
To find the exact location on your machine, run this before deleting:
import matplotlib
print(matplotlib.get_cachedir())
print(matplotlib.get_configdir())
Step 4: Reinstall fresh
python -m pip install matplotlib
This gives you a completely clean installation with no leftover cache files that could cause issues.
How to Uninstall Matplotlib With Conda
If you installed Matplotlib via conda, uninstall it through conda — not pip:
conda remove matplotlib
conda will calculate what to remove and ask for confirmation. It’s smart enough to also flag any packages that depended on Matplotlib.
To uninstall without being asked for confirmation:
conda remove matplotlib -y
Verify That Matplotlib Has Been Uninstalled
After uninstalling, confirm it’s actually gone:
pip show matplotlib
You should see:
WARNING: Package(s) not found: matplotlib
Or try importing it in Python:
python -c "import matplotlib"
You should get:
ModuleNotFoundError: No module named 'matplotlib'
If you still see the module import successfully after uninstalling, you likely have Matplotlib installed in multiple Python environments and you uninstalled it from the wrong one. Check which Python you’re running with:
python -c "import sys; print(sys.executable)"
Then re-run the uninstall using that exact Python:
/path/to/python -m pip uninstall matplotlib
Upgrade Matplotlib in VS Code
VS Code has its own Python interpreter setting. When you upgrade Matplotlib in the terminal, make sure VS Code’s terminal is using the same Python environment.
Open VS Code’s integrated terminal (Terminal > New Terminal), check which Python is active:
python -c "import sys; print(sys.executable)"
Then run the upgrade:
python -m pip install --upgrade matplotlib
If you’re getting old version errors inside VS Code despite upgrading, press Ctrl+Shift+P → Python: Select Interpreter and confirm it’s pointing to the correct environment.
Check out: Matplotlib Best Fit Line
Upgrade Matplotlib in Jupyter Notebook
Upgrade directly from a notebook cell to make sure you’re upgrading into the notebook’s kernel:
%pip install --upgrade matplotlib
After running this, restart the kernel (Kernel > Restart) before importing Matplotlib. This is important — Jupyter caches the old version in memory until you restart.
Verify inside the notebook:
import matplotlib
print(matplotlib.__version__)
Common Questions
Do I need to uninstall before upgrading?
No. pip install –upgrade matplotlib handles the upgrade in place — it removes the old version and installs the new one automatically. You only need to manually uninstall if you’re doing a clean reinstall to fix a broken installation.
Will upgrading Matplotlib break my existing code?
Usually not for minor version upgrades (e.g., 3.8 → 3.9). For major version upgrades, check the Matplotlib changelog for any deprecated functions that were removed. The official release notes at matplotlib.org always list breaking changes.
How do I upgrade only if a newer version is available?
pip install –upgrade matplotlib already does this — it only downloads and installs if there’s a newer version than what you have.
I upgraded Matplotlib, but my plots look different now. What happened?
Matplotlib occasionally changes default style settings between versions, things like default colors, font sizes, or figure dimensions. Check the release notes for your new version. You can also explicitly set a style to keep things consistent: plt.style.use(‘classic’) to restore the older look.
How do I upgrade all outdated packages at once?
bashpip list –outdated
pip install $(pip list –outdated | awk ‘NR>2 {print $1}’) –upgrade
Or more safely, use a tool like pip-review:
pip install pip-review
pip-review –local –interactive
You may also read:
- Save a Matplotlib Plot as a Transparent PNG in Python
- Save NumPy Array as PNG Image in Python Matplotlib
- Save a Matplotlib Plot as PNG Without Borders in Python
- How to Save a Matplotlib Axis as PNG in Python

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.