运行 matplotlib 时不兼容的 libpng 版本

Incompatible libpng versions when running matplotlib

我正在尝试使用 facebook research 的 Detectron。当我 运行 它时,它给了我以下错误:

libpng warning: Application built with libpng-1.6.21 but running with 1.5.12
Traceback (most recent call last):
  File "tools/infer_simple.py", line 147, in <module>
    main(args)
  File "tools/infer_simple.py", line 139, in main
    kp_thresh=2
  File "/home/sid/DETECTRON/detectron/lib/utils/vis.py", line 391, in vis_one_image
    fig.savefig(os.path.join(output_dir, '{}'.format(output_name)), dpi=dpi)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 1834, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 2267, in print_figure
    **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 2595, in print_pdf
    file.finalize()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 595, in finalize
    self.writeImages()
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1430, in writeImages
    ob.id, smaskObject)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1416, in _writeImg
    self._writePng(data)
  File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1366, in _writePng
    _png.write_png(data, buffer)
RuntimeError: Could not create write struct

我 运行宁 Ubuntu 16.04。我不知道应用程序在哪里找到 libpng 1.5.12 版本。我在我的系统中找不到它。我安装了 libpng16-16。它仍然给我同样的错误。我尝试了平台上建议的其他解决方案,但没有用

我猜问题是你 sudo pip 安装了 matplotlib 并且 manylinux matplotlib 安装包附带的 libpng 版本与 [=] 安装的 libpng 版本混淆了13=]。我建议在 .

中使用 matplotlib
# create venv
virtualenv ~/matplotlib-venv

# activate venv
source ~/matplotlib-venv/bin/activate

# install matplotlib
pip install matplotlib
pip install <everything else you need>

# run your script
python ~/path/to/your/srcript.py