Skip to content

[Bug]: AttributeError: module 'matplotlib' has no attribute 'rcParams' #24914

Closed as not planned
@sambaPython24

Description

@sambaPython24

Bug summary

When installing matplotlib in the recommended way with both pip and conda (python 3.9) the import of the packages gives me the error

(I deleted parts of the path to the code file and the Anaconda3 environment)

Code for reproduction

In order to reproduce, use 

import matplotlib.pyplot as plt

in python 3.9 (Anaconda environment), Windows.



### Actual outcome

```python
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
path_to_file\file.py in line 10

---> [10](file:///path_to_file/file.py?line=9) import matplotlib.pyplot as plt


File c\Anaconda3\envs\python39\lib\site-packages\matplotlib\pyplot.py:52
     [50](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/pyplot.py?line=49) from cycler import cycler
     [51](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/pyplot.py?line=50) import matplotlib
---> [52](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/pyplot.py?line=51) import matplotlib.colorbar
     [53](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/pyplot.py?line=52) import matplotlib.image
     [54](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/pyplot.py?line=53) from matplotlib import _api

File \Anaconda3\envs\python39\lib\site-packages\matplotlib\colorbar.py:19
     [16](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/colorbar.py?line=15) import numpy as np
     [18](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/colorbar.py?line=17) import matplotlib as mpl
---> [19](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/colorbar.py?line=18) from matplotlib import _api, cbook, collections, cm, colors, contour, ticker
     [20](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/colorbar.py?line=19) import matplotlib.artist as martist
     [21](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/colorbar.py?line=20) import matplotlib.patches as mpatches

File c:\Users\L470\Anaconda3\envs\python39\lib\site-packages\matplotlib\collections.py:20
     [17](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/collections.py?line=16) import numpy as np
     [19](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/collections.py?line=18) import matplotlib as mpl
---> [20](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/collections.py?line=19) from . import (_api, _path, artist, cbook, cm, colors as mcolors, _docstring,
     [21](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/collections.py?line=20)                hatch as mhatch, lines as mlines, path as mpath, transforms)
     [22](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/collections.py?line=21) from ._enums import JoinStyle, CapStyle
     [25](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/collections.py?line=24) # "color" is excluded; it is a compound setter, and its docstring differs
     [26](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/collections.py?line=25) # in LineCollection.

File \Anaconda3\envs\python39\lib\site-packages\matplotlib\artist.py:16
     [14](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/artist.py?line=13) from . import _api, cbook
     [15](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/artist.py?line=14) from .colors import BoundaryNorm
---> [16](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/artist.py?line=15) from .cm import ScalarMappable
     [17](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/artist.py?line=16) from .path import Path
     [18](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/artist.py?line=17) from .transforms import (Bbox, IdentityTransform, Transform, TransformedBbox,
     [19](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/artist.py?line=18)                          TransformedPatchPath, TransformedPath)

File c:\Anaconda3\envs\python39\lib\site-packages\matplotlib\cm.py:37
     [30](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=29) @_api.caching_module_getattr  # module-level deprecations
     [31](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=30) class __getattr__:
     [32](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=31)     LUTSIZE = _api.deprecated(
     [33](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=32)         "3.5", obj_type="", alternative="rcParams['image.lut']")(
     [34](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=33)             property(lambda self: _LUTSIZE))
---> [37](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=36) _LUTSIZE = mpl.rcParams['image.lut']
     [40](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=39) def _gen_cmap_registry():
     [41](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=40)     """
     [42](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=41)     Generate a dict mapping standard colormap names to standard colormaps, as
     [43](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=42)     well as the reversed colormaps.
     [44](file:///c%3A/Anaconda3/envs/python39/lib/site-packages/matplotlib/cm.py?line=43)     """

AttributeError: module 'matplotlib' has no attribute 'rcParams'

Expected outcome

import matplotlib and use it

Additional information

Importing matplotlib

Operating system

No response

Matplotlib Version

Version 9.1.2023: 3.6

Matplotlib Backend

3.9

Python version

3.9

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions