This error means your code calls a Get_CMap attribute on matplotlib.cm that does not exist, usually due to case, import, or version issues.
What This Matplotlib Attributeerror Really Means
When Python raises an AttributeError, it tells you that an object does not have the attribute you tried to use. In this case the object is the matplotlib.cm module, and the missing attribute name is Get_CMap. Python treats names as case sensitive, so Get_CMap and get_cmap are two different identifiers even though they look close at a glance.
The message Module 'Matplotlib.Cm' Has No Attribute 'Get_CMap' usually points to at least three small mistakes at once. The top level module name uses capital letters, the submodule name does not match the real one, and the attribute name does not match what Matplotlib actually exposes. Each mismatch on its own is enough to break plot code that seemed fine when you wrote it.
Matplotlib ships colormaps through a registry. In classic code you might see import matplotlib.cm as cm and then a call such as cm.get_cmap('viridis'). That pattern still works in many setups, but it depends on the correct module path and the correct function name. If either side does not match, you end up with AttributeError: Module 'Matplotlib.Cm' Has No Attribute 'Get_CMap', even though nothing else in the script looks wrong.
This error does not mean Matplotlib is missing on your machine. It only says that Python could not find the attribute you asked for on the object you gave it. Once you align the import, function call, and version, the same plotting logic can run without any changes to your data.
Why AttributeError: Module ‘Matplotlib.Cm’ Has No Attribute ‘Get_CMap’ Shows Up
This trace often comes from copying code out of an old blog post or a short answer on a forum. Matplotlib has changed over time, and some examples mix different naming styles. Many posts gloss over the exact import lines and focus only on the plotting call, which makes it easy to take a snippet out of context and drop it into a file where the imports look different.
Spelling and case sit at the center of the problem. The real library on disk is named matplotlib, not Matplotlib. The colormap helper module is matplotlib.cm, not Matplotlib.Cm. The function Matplotlib exposes in that module is get_cmap, not Get_CMap. Each mismatch by itself can stop your script. When your code stacks all of them, the message looks noisy but the root cause stays the same.
The next layer comes from Matplotlib version differences. Newer releases added the high level matplotlib.colormaps registry, and some older helpers moved behind that interface. If your base code targets Matplotlib 3.7 or later, it might use matplotlib.colormaps['viridis'] while your current setup still points to an earlier release where that object does not exist. Mixing ideas from both styles is another path to an AttributeError even when every name is spelled with the right case.
Package layout on your machine also plays a part. If you have more than one Python installation, you can end up with several Matplotlib copies without realising it. In that case a notebook, a console session, and a script started from an editor may each reach a different version. One of them might still expose cm.get_cmap, while another throws the attribute error for the same line of code.
Common Patterns Behind The Error
| Pattern You May See | What It Tells You | Typical Fix |
|---|---|---|
import Matplotlib.Cm as Cm |
Module path uses capital letters and a dot that do not match real package names. | Switch to import matplotlib.cm as cm. |
cm.Get_CMap('viridis') |
Function name uses mixed case and an underscore that do not match Matplotlib. | Call cm.get_cmap('viridis') instead. |
matplotlib.colormaps missing |
Code expects a newer Matplotlib colormap registry that your setup lacks. | Upgrade Matplotlib or switch back to cm.get_cmap. |
Taking Care Of The Matplotlib Cm Get Cmap Attributeerror
You can tackle this problem in a short series of checks. The goal is to confirm that you import the right module, call the right function, and run against a version that matches the code you wrote. Each check stands on its own, so you can stop as soon as plots start to work again.
Step One Fix The Import Line
Start with the module path. Your code should import matplotlib.cm with lower case letters, for example import matplotlib.cm as cm. If you wrote import Matplotlib.Cm as Cm, Python will try to load a module that does not exist, and follow up attribute lookups will fail even if the function name looks right.
Keep aliases simple and clear. Short names help, but they should not hide the base import. Patterns such as from matplotlib import cm work, yet they make it easier to forget where cm came from when you return to the file after a break. A direct import with as cm keeps that link in front of you when you scan the script.
Step Two Fix The Function Call
Next, check the function name itself. Change any call that uses Get_CMap to the lower case get_cmap. In Matplotlib this helper sits on the matplotlib.cm module and on matplotlib.pyplot as plt.get_cmap. Both forms reach the same registry and return a colormap object you can pass into plotting calls.
After the function name, check the string you hand in. Names such as 'viridis', 'plasma', and 'gray' ship with Matplotlib. If you misspell the string, Matplotlib raises a different error that still mentions colormaps. That message can stack on top of the AttributeError and make the stack trace harder to read when you scan it for the first time.
Step Three Test In A Clean Session
Once imports and calls look tidy, try a minimal script. Open a fresh Python session and run a tiny test that only imports Matplotlib and calls get_cmap. A short check such as import matplotlib.cm as cm; cm.get_cmap('viridis') tells you whether the library itself works on your machine or whether your project brings extra noise through other dependencies.
In the same clean session, print matplotlib.__version__ and note the string that comes back. Then compare that value with the version your tutorial or sample code expects. Matplotlib 3.7 introduced the newer matplotlib.colormaps path, and some features only appear in those later builds.
Step Four Line Up Your Installation
If a minimal script still fails with an AttributeError, focus on the way Python locates packages on your system. On many setups, different tools ship their own Python copy. Your editor may call one interpreter, while your terminal calls another. Run which python or where python on your platform and match that path with the one your editor points at so that both see the same Matplotlib wheel.
When versions look strange or pip lists more than one Matplotlib entry, a reinstall can clear the clutter. Use pip uninstall matplotlib until it reports nothing to remove, then install once more with pip install matplotlib. After that, repeat the small colormap test to see whether the AttributeError has vanished.
Safer Ways To Work With Colormaps In New Matplotlib Versions
Recent Matplotlib releases expose colormaps through a top level registry that hangs off the library. You can still reach many helpers under matplotlib.cm, yet the new route gives you a clear and direct way to grab the map you need for your data.
- Use the colormaps registry Import
colormapsfrom Matplotlib and request a map with square bracket access, such asfrom matplotlib import colormapsthencmap = colormaps['viridis']. - Call pyplot helpers If your code already leans on
matplotlib.pyplotasplt, you can askplt.get_cmap('viridis')for the map and pass the result into plot calls. - List available names When you are not sure which map to pick, call
plt.colormaps()or usecolormaps.keys()on the registry to see which strings are valid for your release.
These patterns line up with the direction Matplotlib itself has taken. Code that uses the registry stays closer to current examples in the reference pages, and that in turn makes it easier to share snippets with other people who may run them on a different machine.
Debugging Checklist For Attribute Errors In Plot Code
While the string AttributeError: Module 'Matplotlib.Cm' Has No Attribute 'Get_CMap' looks specific, the pattern behind it shows up across many Matplotlib issues. Once you get comfortable reading these traces, you can fix other plot problems using the same habits.
- Read the full message Scan the text after
AttributeErrorand note which object and attribute Python names. - Check the import line Confirm that the module path in your code matches the real package path, including case.
- Check the attribute spelling Compare the attribute in your call with the one in the official Matplotlib reference for your version.
- Reproduce in a small script Strip your code to a few lines that still raise the error, then work from there so you can see each change clearly.
- Compare versions Match your installed Matplotlib release with the one your example code was written for, and align the calls with that release.
These steps line up with the way Python presents errors. The message always names the object that failed and the attribute that did not match. Once you get used to mapping those pieces back to your imports and function calls, stack traces stop feeling like walls of text and start to turn into helpful feedback.
Final Checks And Good Habits For Plot Code
Error strings such as AttributeError: Module 'Matplotlib.Cm' Has No Attribute 'Get_CMap' can break your flow when you just want to see a quick figure. The fix rarely hides in deep Matplotlib internals though. It almost always comes down to clean imports, stable versions, and clear function calls that match the reference.
In any project that matters to you, write down the Python and Matplotlib versions in a requirements.txt file or a short note in your repository. When you upgrade, do it on purpose and run a short plot script to confirm that colormap calls still behave as you expect. That habit keeps surprises away when you open an old notebook months later.
If you maintain notebooks or teaching material, revisit them from time to time and bring imports and colormap calls in line with current Matplotlib releases. That habit reduces the chance that a reader copies a line with Get_CMap out of old code and runs straight into the same AttributeError you just fixed.
Each time Python stops with an AttributeError, pause and read the message slowly. Look for the object name, the missing attribute, and the line that triggered it. That small pause turns error text from noise into guidance that points to the exact place you need to adjust. Over time, a message like AttributeError: Module 'Matplotlib.Cm' Has No Attribute 'Get_CMap' turns from a dead end into a quick reminder to check spelling, imports, and version. Your plots get back on screen, your colormaps behave as intended, and your code base grows cleaner each time you tidy up an AttributeError.
