运行matplotlib出错

本人使用的操作系统是Ubuntu17.04,Python3.7 按照网站上的安装方法安装matplotlib,安装好后,在使用时出现以下问题:

>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/space-wa/.local/lib/python3.7/site-packages/matplotlib/__init__.py", line 134, in <module>
    import subprocess
  File "/usr/lib/python3.7/subprocess.py", line 152, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
    import subprocess, tempfile, os.path, re, pwd, grp, os, time
  File "/usr/lib/python3.7/subprocess.py", line 152, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'

Original exception was:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/space-wa/.local/lib/python3.7/site-packages/matplotlib/__init__.py", line 134, in <module>
    import subprocess
  File "/usr/lib/python3.7/subprocess.py", line 152, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'

按照提示,我直接对这个包进行重新安装,期待将旧的版本替代,但是还是出现同样的问题。

萌新求指教!

阅读 3.8k
1 个回答

按下面试试重装下

pip3 uninstall subprocess32
pip3 install -U subprocess32
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏