在需要使用matplotlib在py文件中画图时,导入这个包的同时可能会出现以下问题:
在import matplotlib.pyplot as plt时出现:
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-4c7itqfv because the default path (/home/xx/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
原因不详。
解决方法:
在import matplotlib.pyplot as plt之前:
import os
os.environ['MPLCONFIGDIR'] = os.getcwd() + "/configs/"
import matplotlib.pyplot as plt