Matplotlib 创建了一个临时 config/cache 目录

yas*_*han 10 django matplotlib django-wsgi python-3.x

Matplotlib 在 /var/www/.config/matplotlib 创建了一个临时 config/cache 目录,因为默认路径 (/tmp/matplotlib-b33qbx_v) 不是可写目录;强烈建议将 MPLCONFIGDIR 环境变量设置为可写目录,特别是为了加快 Matplotlib 的导入速度并更好地支持多处理。

这是我在 error.log 文件和浏览器上的 504 Gateway Time out error 中收到的消息。请有人帮助解决这个问题。

小智 7

请检查: https: //github.com/pyinstaller/pyinstaller/issues/617

我从网络服务器运行 matplotlib 并使用: os.environ['MPLCONFIGDIR'] = '/opt/myapplication/.config/matplotlib' 该目录应该可由网络服务器写入(例如 www-data)。


小智 6

导入 os os.environ['MPLCONFIGDIR'] = os.getcwd() + "/configs/"

导入 matplotlib

为我工作