【发布时间】:2015-05-18 09:19:58
【问题描述】:
我在 Ubuntu 14.04 上使用 matplotlib 1.3.1 和 python 3.4.0。我想在.config/matplotlib/matplotlibrc 中使用matplotlibrc configuration file。但是似乎 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)
我matplotlibrc的内容是here的默认内容。
如何让matplotlib找到配置文件?
编辑:
>>> matplotlib.get_configdir()
'/home/<me>/.matplotlib'
【问题讨论】:
-
你从
matplotlib.get_configdir()得到什么? -
你有正确的权限来阅读~/.config/matplotlib/matplotlibrc吗?
chmod u+rwx ~/.config/matplotlib和chmod u+r ~/.config/matplotlib/matplotlibrc可能会有所帮助。 -
@Marius 查看我对问题的编辑。
-
好的,所以看起来您应该将 matplotlibrc 文件放在
~/.matplotlib而不是~/.config/matplotlib中。不知道为什么配置路径会改变。 -
@Marius 但是当我这样做时,我会收到消息
UserWarning: Found matplotlib configuration in ~/.matplotlib/. To conform with the XDG base directory standard, this configuration location has been deprecated on Linux, and the new location is now '/home/me/.config'/matplotlib/. Please move your configuration there to ensure that matplotlib will continue to find it in the future.所以我想使用正确的位置,或者至少摆脱警告。
标签: python python-3.x matplotlib configuration