The error AttributeError: module 'matplotlib' has no attribute 'artist' occurs during Matplotlib’s import process, often before your code draws a plot. The message alone does not reveal why it happened. Start by reading the full traceback, then confirm which Python interpreter and Matplotlib installation your failing process is actually using before changing packages.
What the error means—and what it does not prove
In a Matplotlib project report, importing matplotlib.pyplot failed when matplotlib.colorbar tried to import matplotlib.artist. That report documented Windows 10, Python 3.6.7, and Matplotlib 3.0.0 installed from Anaconda’s default channel; the reporter said the problem began after package updates but could not identify an update as the cause. It is a historical, environment-specific case, not proof that every matching error has the same cause. Matplotlib issue #12626
As an Amazon Associate I earn from qualifying purchases.
The exception tells you that an expected attribute or submodule was unavailable at a point in the import chain. It does not, on its own, establish whether the installation is damaged, a different Python environment is being used, a project file is interfering with imports, or some other condition is involved. Use the traceback and the checks below to narrow it down.
Free tools Windows power users keep installed
One-click scans. No signup required.
1. Read the full traceback
Do not rely only on the final error line. Find the failing import and the first traceback frame outside Matplotlib. That frame may point to the code or environment that initiated the import. In the historical report, the internal failure occurred at matplotlib.colorbar while it imported matplotlib.artist; your traceback may be different.
#1 Best Overall
- Note the exact line of your code that triggered the import.
- Look for the first frame outside the Matplotlib package and any local files named in it.
- Keep the complete traceback available while testing, so you can tell whether a change moves or resolves the failure.
2. Check which Python and Matplotlib are running
Run these checks in the same terminal, IDE, or notebook kernel that produces the error. Matplotlib’s installation guide documents checking the version and installed file location. Matplotlib installation and troubleshooting documentation
import sys
import matplotlib
print(sys.executable)
print(matplotlib.__version__)
print(matplotlib.__file__)
Compare sys.executable with the Python environment you intended to use. Compare matplotlib.__file__ with the location where you expected Matplotlib to be installed. If either points somewhere unexpected, you may be running a different interpreter or package installation than the one you meant to repair.
Rank #2
3. Look for names in your project that conflict with Matplotlib
Check your working directory and project for a file named matplotlib.py or a directory named matplotlib. Python imports modules by name, so a local name can affect which module is found. This is a diagnostic possibility, not a confirmed explanation for the Matplotlib issue above. Python tutorial: Modules
If you find a conflict, rename the file or directory, remove any stale __pycache__ entries for the renamed module if present, and restart the Python process before testing again. Restarting matters because an already-running interpreter may retain modules it has imported.
4. Test in a clean process
Try a short script from a shell or command prompt, rather than a notebook cell or IDE session. Matplotlib’s troubleshooting guidance recommends using a standalone script to help separate interactive-shell or IDE complications from the package environment.
import matplotlib
import matplotlib.pyplot as plt
print(matplotlib.__version__)
print(matplotlib.__file__)
Run it with the Python executable you identified in step 2. If it succeeds in the clean process but fails only in a notebook or IDE, check that application’s selected interpreter or kernel and restart it. If it fails there too, continue with an environment repair.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.5. Repair the environment you confirmed
Choose the installation method that matches the environment and package manager you actually use. Matplotlib documents pip, conda, pixi, and uv installation routes; prebuilt packages are recommended where possible for production installations. Do not mix package managers casually in a managed environment.
For a pip-managed environment
Use the confirmed Python executable to target its pip installation. The documented pip upgrade command is:
Best Value
python -m pip install -U matplotlib
If the failing process uses a specific Python command or virtual environment, invoke that executable instead of assuming the shell’s generic python selects the right one.
For a conda-managed environment
Activate the intended conda environment first, then use the conda installation route in Matplotlib’s official guide. Avoid repairing it with pip unless you specifically understand how that will interact with packages managed by conda.
For pixi or uv
Use the corresponding workflow in Matplotlib’s installation guide and target the project environment used by the failing process. The correct command depends on how that environment was created and managed.
Recommended Free Tools
6. Verify the result
After a repair, restart the IDE, notebook kernel, or Python process and repeat the version and location checks. Confirm that the path and version now correspond to the environment you intended, then retry the original import. If the resolved path did not change, the repair may have targeted another Python installation; return to the interpreter check rather than repeating the same install command blindly.
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.




