ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

Installing matplotlib into Ubuntu 18.04

2021-02-27 20:02:10  阅读:375  来源: 互联网

标签:lib 18.04 into py Installing matplotlib File import line


  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:

 

 

 

 

 

 

 

  

标签:lib,18.04,into,py,Installing,matplotlib,File,import,line
来源: https://blog.csdn.net/qq_39597358/article/details/114187374

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有