Installing matplotlib into Ubuntu 18.04

  File "/home/lee/share/py_lab/matplotlib_animation/src/test001.py", line 2, in <module>
    from matplotlib import animation,pyplot
  File "/home/lee/share/py_lab/env001_matplot_animate/lib/python3.8/site-packages/matplotlib/pyplot.py", line 36, in <module>
    import matplotlib.colorbar
  File "/home/lee/share/py_lab/env001_matplot_animate/lib/python3.8/site-packages/matplotlib/colorbar.py", line 44, in <module>
    import matplotlib.contour as contour
  File "/home/lee/share/py_lab/env001_matplot_animate/lib/python3.8/site-packages/matplotlib/contour.py", line 17, in <module>
    import matplotlib.text as text
  File "/home/lee/share/py_lab/env001_matplot_animate/lib/python3.8/site-packages/matplotlib/text.py", line 16, in <module>
    from .textpath import TextPath  # Unused, but imported by others.
  File "/home/lee/share/py_lab/env001_matplot_animate/lib/python3.8/site-packages/matplotlib/textpath.py", line 11, in <module>
    from matplotlib.mathtext import MathTextParser
  File "/home/lee/share/py_lab/env001_matplot_animate/lib/python3.8/site-packages/matplotlib/mathtext.py", line 27, in <module>
    from PIL import Image
  File "/usr/lib/python3/dist-packages/PIL/Image.py", line 68, in <module>
    from PIL import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL' (/usr/lib/python3/dist-packages/PIL/__init__.py)

python imports matplotlib from virtual env

PIL from system python path

which leads to version conflict

 

run sudo pip uninstall pillow in system shell

then pip install pillow in virtual env

helloword
/home/lee/share/py_lab/matplotlib_animation/src/test001.py:19: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.
  pyplot.show()

It means we need a new GUI backend

 

import matplotlib.rcsetup as rcsetup
print(rcsetup.all_backends)
['GTK3Agg', 'GTK3Cairo', 'MacOSX', 'nbAgg', 'Qt4Agg', 'Qt4Cairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']

try:

matplotlib.use('QT5Agg')

then:

File "/home/lee/share/py_lab/env002_matplot_animate/lib/python3.8/site-packages/matplotlib/pyplot.py", line 277, in backend_mod
    locals().update(vars(importlib.import_module(backend_name)))
  File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/lee/share/py_lab/env002_matplot_animate/lib/python3.8/site-packages/matplotlib/backends/backend_qt5agg.py", line 11, in <module>
    from .backend_qt5 import (
  File "/home/lee/share/py_lab/env002_matplot_animate/lib/python3.8/site-packages/matplotlib/backends/backend_qt5.py", line 16, in <module>
    import matplotlib.backends.qt_editor.figureoptions as figureoptions
  File "/home/lee/share/py_lab/env002_matplot_animate/lib/python3.8/site-packages/matplotlib/backends/qt_editor/figureoptions.py", line 11, in <module>
    from matplotlib.backends.qt_compat import QtGui
  File "/home/lee/share/py_lab/env002_matplot_animate/lib/python3.8/site-packages/matplotlib/backends/qt_compat.py", line 177, in <module>
    raise ImportError("Failed to import any qt binding")
ImportError: Failed to import any qt binding

try:

pip3 install pyqt5

then: 

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl, xcb.

Aborted (core dumped)

 

try:

sudo apt-get install libxcb-xinerama0

then:

 

 

 

 

 

 

 

  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值