This error originated from matplotlib version 3.9.0. Try to install older version which might solve your issue:

pip install matplotlib==3.7.3
Answer from Ja X on Stack Overflow
🌐
Image.sc
forum.image.sc › usage & issues
AttributeError of testscript: module 'matplotlib.cm' has no attribute 'get_cmap' - Usage & Issues - Image.sc Forum
May 16, 2024 - Hi When I installed everything required and wanted to test if the DLC is working correctly using the testscript.py, an AttributeError pops out. Does anyone have any idea of how to fix it? Many thank! (DEEPLABCUT) C:\Us…
Discussions

module 'matplotlib.cm' has no attribute 'cmap_d'
Hi, Please can you help me with solving the following error? Here is the traceback (I am running NanoPlot from within a conda environment, installed using conda, NanoPlot version: 1.30.1): Tracebac... More on github.com
🌐 github.com
4
June 4, 2023
Importing seaborn package
Bug summary Hello. This issue happen when I try to import the " seaborn " library from a python program in visual studio code. I use !pip command to download jupyter, ipython, matplotlib ... More on github.com
🌐 github.com
4
July 26, 2024
Matlplotlib after installed by CONDA missing matplotlib.cm.cmap
Is there an existing issue for this? I have searched the existing issues Bug description Hi, I am trying the demo . I used conda to install DeepLabCut. However, I got this error of not finding cmap in matplotlib when I finished training ... More on github.com
🌐 github.com
11
May 16, 2024
Matplotlib Errors: module 'matplotlib.cm' - Anaconda & Miniconda - Anaconda Forum
Hey, I am getting these errors with I try and use Matplotlib or Seaborn. I am using Python 3.12.3 · I’m assuming you’ve figured it out, but if not I just ran into the same issue setting up a new environment. Installing the latest package from conda forge fixed the problem for me. More on forum.anaconda.com
🌐 forum.anaconda.com
0
December 3, 2024
🌐
Matplotlib
matplotlib.org › stable › api › cm_api.html
matplotlib.cm — Matplotlib 3.11.2 documentation
The colormap name can then be used as a string argument to any cmap parameter in Matplotlib.
🌐
GitHub
github.com › wdecoster › NanoPlot › issues › 333
module 'matplotlib.cm' has no attribute 'cmap_d' · Issue #333 · wdecoster/NanoPlot
June 4, 2023 - Traceback (most recent call last): File "/Users/amir/Assembly_ONT/.snakemake/conda/4662e0a5ca323c0a576ce5c7b9180b4e/bin/NanoPlot", line 10, in sys.exit(main()) File "/Users/amir/Assembly_ONT/.snakemake/conda/4662e0a5ca323c0a576ce5c7b9180b4e/lib/python3.10/site-packages/nanoplot/NanoPlot.py", line 97, in main plots = make_plots(datadf, settings) File "/Users/amir/Assembly_ONT/.snakemake/conda/4662e0a5ca323c0a576ce5c7b9180b4e/lib/python3.10/site-packages/nanoplot/NanoPlot.py", line 134, in make_plots colormap = nanoplotter.check_valid_colormap(settings["colormap"]) File "/Users/amir/Assembly_ONT/.snakemake/conda/4662e0a5ca323c0a576ce5c7b9180b4e/lib/python3.10/site-packages/nanoplotter/nanoplotter_main.py", line 65, in check_valid_colormap if colormap in list(cm.cmap_d.keys()): AttributeError: module 'matplotlib.cm' has no attribute 'cmap_d'
Author: wdecoster
🌐
GitHub
github.com › matplotlib › matplotlib › issues › 28618
Importing seaborn package · Issue #28618 · matplotlib/matplotlib
July 26, 2024 - I look at the cm.py file related to the matplotlib package and I found that there is no definition of the function : register_cmap ()
Author: matplotlib
🌐
GitHub
github.com › DeepLabCut › DeepLabCut › issues › 2581
Matlplotlib after installed by CONDA missing matplotlib.cm.cmap · Issue #2581 · DeepLabCut/DeepLabCut
May 16, 2024 - Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/chz31/DeepLabCut/deeplabcut/pose_estimation_tensorflow/core/evaluate.py", line 1019, in evaluate_network Plotting( File "/home/chz31/DeepLabCut/deeplabcut/pose_estimation_tensorflow/core/evaluate.py", line 201, in Plotting colors = visualization.get_cmap(len(comparisonbodyparts), name=cfg["colormap"]) File "/home/chz31/DeepLabCut/deeplabcut/utils/visualization.py", line 36, in get_cmap return plt.cm.get_cmap(name, n) AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap' After activating conda activate DEEPLABCUT, the Python used is 3.9.
Author: DeepLabCut
🌐
Anaconda Forum
forum.anaconda.com › product help › anaconda & miniconda
Matplotlib Errors: module 'matplotlib.cm' - Anaconda & Miniconda - Anaconda Forum
December 3, 2024 - Hey, I am getting these errors with I try and use Matplotlib or Seaborn. I am using Python 3.12.3 · I’m assuming you’ve figured it out, but if not I just ran into the same issue setting up a new environment. Installing the latest package from conda forge fixed the problem for me.
🌐
Reddit
reddit.com › r/learnpython › matplotlib: assigning random colormap > attributeerror: module 'matplotlib.cm' has no attribute 'random_cmap'
r/learnpython on Reddit: Matplotlib: assigning random colormap > AttributeError: module 'matplotlib.cm' has no attribute 'random_cmap'
October 17, 2022 -

I'd like to use a randomly selected (from a list of accepted attributes, of course) colormap. Evidently I get this error: AttributeError: module 'matplotlib.cm' has no attribute 'random_cmap'

Is this possible without writing a separate function, returning cmap=plt.cm.xyz?

import matplotlib.pyplot as plt
from random import choice

available_cmaps =('viridis', 'plasma', 'inferno', 'magma', 'cividis',
        'PiYG', 'PRGn', 'BrBG', 'PuOr', 'Spectral', 
        'gist_ncar', 'nipy_spectral', 'terrain', 'prism', 'ocean')
random_cmap = choice(available_cmaps)

#snip


ax.scatter(x_values, y_values, c=numbers,
        cmap=plt.cm.random_cmap, s=8)

Note, the above code does not work, because matplotlib.cm has no attribute 'random_cmap'

One of the reason I would like to not write a separate function is because I am going to include the randomly selected colormap string as part of the title, thus having easy access to the variable without randomly selecting it again.

Thanks in advance.

EDIT: solved. I can use cmap=random_cmap

This allows me to use the string variable random_cmap for other purposes, such as in the title.

Find elsewhere
🌐
GitHub
github.com › matplotlib › matplotlib › issues › 28349
[Bug]: `matplotlib.cm.get_cmap()` missing · Issue #28349 · matplotlib/matplotlib
June 5, 2024 - In [1]: from matplotlib import pyplot, cm In [2]: pyplot.get_cmap('gray') Out[2]: <matplotlib.colors.LinearSegmentedColormap at 0x7f6b2c7303d0> In [3]: cm.get_cmap('gray') --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[3], line 1 ----> 1 cm.get_cmap('gray') AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap'
Author: matplotlib
🌐
Matplotlib
matplotlib.org › 2.2.5 › _modules › matplotlib › cm.html
matplotlib.cm — Matplotlib 2.2.5 documentation
February 9, 2020 - """ from __future__ import (absolute_import, division, print_function, unicode_literals) import six import numpy as np from numpy import ma import matplotlib as mpl import matplotlib.colors as colors import matplotlib.cbook as cbook from matplotlib._cm import datad from matplotlib._cm_listed import cmaps as cmaps_listed cmap_d = {} # reverse all the colormaps.
🌐
GitHub
github.com › anyoptimization › pymoo › issues › 596
AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap' when using Matplotlib 3.9.0 · Issue #596 · anyoptimization/pymoo
May 21, 2024 - AttributeError caused by new matplotlib version 3.9.0 as described here: luciddreamer-cvlab/LucidDreamer#56 more info: https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.9.0.html
Author: anyoptimization
🌐
Matplotlib
matplotlib.org › 3.4.3 › _modules › matplotlib › cm.html
matplotlib.cm — Matplotlib 3.4.3 documentation
August 13, 2021 - """ _api.check_isinstance((str, None), name=name) if name is None: try: name = cmap.name except AttributeError as err: raise ValueError("Arguments must include a name or a " "Colormap") from err if name in _cmap_registry: if not override_builtin and name in __builtin_cmaps: msg = f"Trying to re-register the builtin cmap {name!r}." raise ValueError(msg) else: msg = f"Trying to register the cmap {name!r} which already exists."
🌐
GitHub
github.com › matplotlib › matplotlib › issues › 12075
'matplotlib' has no attribute 'cm' when deploying an app · Issue #12075 · matplotlib/matplotlib
September 10, 2018 - When I run locally the application, it runs smoothly and everything is okay, however, when I deploy it using the same code (I'm deploying using heroku) the matplotlib version that is installed (which is the current 2.2.3) no longer find the attrbute 'cm' to create a colormap.
Author: matplotlib
🌐
Matplotlib
matplotlib.org › 2.2.3 › _modules › matplotlib › cm.html
matplotlib.cm — Matplotlib 2.2.3 documentation
""" from __future__ import (absolute_import, division, print_function, unicode_literals) import six import numpy as np from numpy import ma import matplotlib as mpl import matplotlib.colors as colors import matplotlib.cbook as cbook from matplotlib._cm import datad from matplotlib._cm_listed import cmaps as cmaps_listed cmap_d = {} # reverse all the colormaps.
🌐
Beautiful Soup
tedboy.github.io › mpl › _modules › matplotlib › cm.html
matplotlib.cm
""" from __future__ import (absolute_import, division, print_function, unicode_literals) from matplotlib.externals import six import os import numpy as np from numpy import ma import matplotlib as mpl import matplotlib.colors as colors import matplotlib.cbook as cbook from matplotlib._cm import datad from matplotlib._cm import cubehelix from matplotlib._cm_listed import cmaps as cmaps_listed cmap_d = dict() # reverse all the colormaps.
🌐
GitHub
github.com › mapillary › OpenSfM › issues › 1116
Potential compatibility issues with matplotlib.cm.get_cmap (Incompatible with Matplotlib 3.9.0) · Issue #1116 · mapillary/OpenSfM
February 12, 2026 - >>> import matplotlib >>> print(matplotlib.__version__) 3.9.0 >>> from matplotlib import cm >>> cmap = cm.get_cmap(None) Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: module 'matplotlib.cm' has no attribute 'get_cmap'
Author: mapillary
🌐
Pydocs
pydocs.github.io › p › matplotlib › 3.5.1 › api › matplotlib.cm.register_cmap.html
register_cmap
Registering a colormap stores a reference to the colormap object which can currently be modified and inadvertently change the global colormap state. This behavior is deprecated and in Matplotlib 3.5 the registered colormap will be immutable.