问题描述
我正在尝试让matplotlib与WSL2(适用于Linux 2的Windows子系统)一起使用。 我已按照这篇文章中的所有说明进行操作:https://stackoverflow.com/a/43399827/12851544 但不幸的是它没有用。 我需要使用python2.7,因为我想使用以下C ++库:https://github.com/lava/matplotlib-cpp
与X服务器(VcXsrv)的连接工作正常,因为我能够从WSL2启动xcalc。但是,只要我运行一个简单的python代码来测试matplotlib,我就会收到以下错误:
Traceback (most recent call last):
File "test.py",line 1,in <module>
import matplotlib.pyplot as plt
File "/home/marcel/.local/lib/python2.7/site-packages/matplotlib/pyplot.py",line 115,in <module>
_backend_mod,new_figure_manager,draw_if_interactive,_show = pylab_setup()
File "/home/marcel/.local/lib/python2.7/site-packages/matplotlib/backends/__init__.py",line 63,in pylab_setup
[backend_name],0)
File "/home/marcel/.local/lib/python2.7/site-packages/matplotlib/backends/backend_gtkagg.py",line 12,in <module>
from matplotlib.backends.backend_gtk import (
File "/home/marcel/.local/lib/python2.7/site-packages/matplotlib/backends/backend_gtk.py",line 21,in <module>
raise ImportError("Gtk* backend requires pygtk to be installed.")
ImportError: Gtk* backend requires pygtk to be installed.
我尝试使用pip安装pygtk,但随后出现以下错误:
Collecting pygtk
Downloading https://files.pythonhosted.org/packages/7c/18/fa4f2de77500dd62a314fd845ff6e903ac2ce551164cb421c5750969f799/pygtk-2.24.0.tar.bz2 (2.4MB)
100% |████████████████████████████████| 2.4MB 737kB/s
Complete output from command python setup.py egg_info:
********************************************************************
* Building PyGTK using distutils is only supported on windows. *
* To build PyGTK in a supported way,read the INSTALL file. *
********************************************************************
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-GMX7ld/pygtk/
python-tk已经安装(版本2.7.17-1〜18.04)。
我也使用python3.6进行了测试,但出现了相同的错误。
希望有人可以帮助我。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)