Python matplotlib找不到配置文件matplotlibrc
我正在Ubuntu 14.04上使用matplotlib 1.3.1和python 3.4.0。我想在Python matplotlib找不到配置文件matplotlibrc,python,python-3.x,matplotlib,configuration,Python,Python 3.x,Matplotlib,Configuration,我正在Ubuntu 14.04上使用matplotlib 1.3.1和python 3.4.0。我想在.config/matplotlib/matplotlibrc中使用。但是,matplotlib似乎无法找到它: ~$ ls ~/.config/matplotlib/ matplotlibrc ~$ python3 Python 3.4.0 (default, Apr 11 2014, 13:05:11) [GCC 4.8.2] on linux Type "help", "copyrigh
.config/matplotlib/matplotlibrc
中使用。但是,matplotlib似乎无法找到它:
~$ ls ~/.config/matplotlib/
matplotlibrc
~$ python3
Python 3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
/usr/lib/python3/dist-packages/matplotlib/__init__.py:766: UserWarning: Could not find matplotlibrc; using defaults
warnings.warn('Could not find matplotlibrc; using defaults')
/usr/lib/python3/dist-packages/matplotlib/__init__.py:882: UserWarning: could not find rc file; returning defaults
warnings.warn(message)
mymatplotlibrc
的内容是中的默认内容
如何使matplotlib找到配置文件
编辑:
>matplotlib.get\u configdir()
“/home/.matplotlib”
从matplotlib.get\u configdir()
的docstring中,我发现如果存在.matplotlib/
,matplotlib将不会在~/.config
中查找
因此,即使存在~/.config/matplotlib/matplotlibrc
,也应该完全删除~/.matplotlib
目录
请注意,我后来也不得不这样做。我在这里找到了我的,而不必删除.matplotlib目录
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site packages/matplotlib/mpl data/matplotlibrc您从
matplotlib.get\u configdir()
中获得了什么?您是否具有读取~/.config/matplotlib/matplotlibrc的正确权限chmod u+rwx~/.config/matplotlib
和chmod u+r~/.config/matplotlib/matplotlibrc
可能会有帮助。@马吕斯看到我对这个问题的编辑。好的,看来你应该把matplotlibrc文件放到~/.matplotlib
而不是~/.config/matplotlib
中。不确定为什么配置路径会发生更改。@Marius但当我这样做时,我会收到消息UserWarning:Found matplotlib configuration in ~/.matplotlib/。为了符合XDG基本目录标准,Linux上不推荐使用此配置位置,新位置现在是“/home/me/.config”/matplotlib/。请将您的配置移到那里,以确保matplotlib将来会继续找到它。
因此我希望使用正确的位置,或者至少消除警告。
>>> matplotlib.get_configdir()
'/home/<me>/.matplotlib'