matplotlib 中的 MPLCONFIGDIR 错误
当我尝试导入 matplotlib.pyplot 时,出现以下错误:
RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "% (h, h))
我的主目录中有一个 .matplotlib 目录,该目录归我所有并具有写入权限。那么为什么它告诉我它“不是可写的目录”以及如何解决这个问题?
When I try to import matplotlib.pyplot I get the following error:
RuntimeError("'%s' is not a writable dir; you must set %s/.matplotlib to be a writable dir. You can also set environment variable MPLCONFIGDIR to any writable directory where you want matplotlib data stored "% (h, h))
I do have a .matplotlib directory in my home directory which is owned by me and has write permissions on. So why is it telling me it is "not a writable dir" and how do I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要以 root 身份运行 Python;它并不真正安全,以后您可能会遇到更多权限问题。相反,只需确保您拥有主目录和 matplotlib 目录:
Don't run Python as root; it not really safe, and you will potentially just run into more permissions issues later. Instead, just make sure you own the home directory and matplotlib directory:
将
MPLCONFIGDIR
设置为“/tmp/”,如本指南Set
MPLCONFIGDIR
to '/tmp/', as described in this guide