Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: 3.5.0rc1: MPLCONFIGDIR no longer supported to load custom configurations? #21375

Closed
@sandrotosi

Description

@sandrotosi

Bug summary

Hello,
while packaging 3.5.0rc1, i notice that it's no longer possible to set a custom matplotlibrc, if the default one is "invalid".

# MPLCONFIGDIR=. PYTHONPATH=/build/matplotlib-3.5.0~rc1/build/lib.linux-x86_64-3.9 python3
Python 3.9.7 (default, Sep 24 2021, 09:43:00) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
rcfile /usr/share/matplotlib/mpl-data/matplotlibrc
<stdin>:1: MatplotlibDeprecationWarning: 
The mpl_toolkits.legacy_colorbar rcparam was deprecated in Matplotlib 3.4 and will be removed two minor releases later. Please update your matplotlibrc.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/build/matplotlib-3.5.0~rc1/build/lib.linux-x86_64-3.9/matplotlib/__init__.py", line 896, in <module>
    defaultParams = rcsetup.defaultParams = {
  File "/build/matplotlib-3.5.0~rc1/build/lib.linux-x86_64-3.9/matplotlib/__init__.py", line 899, in <dictcomp>
    rcParamsDefault[key]),
  File "/build/matplotlib-3.5.0~rc1/build/lib.linux-x86_64-3.9/matplotlib/__init__.py", line 674, in __getitem__
    return dict.__getitem__(self, key)
KeyError: 'pcolormesh.snap'

(that's because /usr/share/matplotlib/mpl-data/matplotlibrc is a template file in Debian's setup); the same exact error happens even setting MATPLOTLIBRC=./matplotlibrc, as specified in the doc the doc).

This used to work, and it's the way how we set specific settings for our build environment (like backend, etc).

looking at the code in __init__.py it appears _rc_params_in_file() is always executed against what cbook._get_data_path("matplotlibrc") returns, which with a couple of hoops results in a static file (mind that we customize this location in debian as seen here, which is the path you see above ).

Without the possibility to either use MPLCONFIGDIR or MATPLOTLIBRC, building matplotlib in Debian becomes quite hard. Is this just an oversight and support should be re-introduced, or is this a conscious decision?

thanks,
Sandro

Code for reproduction

see above

Actual outcome

traceback

Expected outcome

no traceback

Operating system

Debian

Matplotlib Version

3.5.0rc1

Matplotlib Backend

No response

Python version

3.9.7

Jupyter version

No response

Other libraries

No response

Installation

source

Conda channel

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions