python - matplotlib 字体管理器出错
问题描述
我正在尝试在我的服务器上运行一个简单的脚本来测试 matplolib。脚本就这么简单:
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt # no error here, it works
plt.figure(1).show()
但是,执行它是不可能的,我收到了这个错误:老实说,我没有想法了
Traceback (most recent call last):
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/font_manager.py", line 1459, in <module>
fontManager = json_load(_fmcache)
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/font_manager.py", line 986, in json_load
return json.load(fh, object_hook=_json_decode)
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/json/__init__.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/json/__init__.py", line 332, in loads
return cls(**kw).decode(s)
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/font_manager.py", line 977, in json_dump
json.dump(data, fh, cls=JSONEncoder, indent=2)
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/json/__init__.py", line 179, in dump
fp.write(chunk)
OSError: [Errno 28] No space left on device
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test2.py", line 3, in <module>
import matplotlib.pyplot as plt # no error, it works
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/pyplot.py", line 31, in <module>
import matplotlib.colorbar
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/colorbar.py", line 36, in <module>
import matplotlib.contour as contour
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/contour.py", line 20, in <module>
import matplotlib.font_manager as font_manager
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/font_manager.py", line 1469, in <module>
_rebuild()
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/font_manager.py", line 1454, in _rebuild
json_dump(fontManager, _fmcache)
File "/share/CACHEDEV1_DATA/.qpkg/Python3/python3/lib/python3.5/site-packages/matplotlib/font_manager.py", line 979, in json_dump
warnings.warn('Could not save font_manager cache ', e)
TypeError: category must be a Warning subclass, not 'OSError'
解决方案
推荐阅读
- python - 未使用 pytest 错误处理测试运行的子进程
- python - 何可以将损失函数保存在for循环中?
- java - FFMPEG profile-level-id 大小无效
- java - 如何从 jar 而不是 .java 文件在 S3 上创建私有 Maven 存储库?
- c++ - “未定义的类”作为 is_base_of 的参数
- javascript - BST插入方法JS获取无限循环
- linux - 在 bash 脚本中检查文件的所有者权限(多路径结果)
- asp.net-mvc - 与客户端版本相比,SignalR 在 Windows 服务中无法正常工作
- sql - SQL中的分区和连续
- selenium - 在硒的新标签中打开一个链接