我用pip(9.0.1)下的Python 3.6(在Xubuntu 16.04),但没有图像显示时,我试图阴谋的东西。
使用ipython3 --matplotlib qt
启动ipython会出现以下错误:
ImportError: Matplotlib qt-based backends require an external PyQt4, PyQt5,
or PySide package to be installed, but it was not found.
我试着用pip安装这些,但失败了:
$ pip3.6 install PySide
Collecting PySide
Downloading PySide-1.2.4.tar.gz (9.3MB)
100% |████████████████████████████████| 9.3MB 12.8MB/s
Complete output from command python setup.py egg_info:
only these python versions are supported: [(2, 6), (2, 7), (3, 2), (3, 3), (3, 4)]
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-bzzpzy5q/PySide/
$ pip3.6 install PyQT
Collecting PyQT
Could not find a version that satisfies the requirement PyQT (from versions: )
No matching distribution found for PyQT
$ pip3.6 install PyQT4
Collecting PyQT4
Could not find a version that satisfies the requirement PyQT4 (from versions: )
No matching distribution found for PyQT4
$ pip3.6 install PyQT5
Collecting PyQT5
Could not find a version that satisfies the requirement PyQT5 (from versions: )
No matching distribution found for PyQT5
如果我尝试ipython3 --matplotlib gtk
,错误是:
ImportError: Gtk* backend requires pygtk to be installed.
但是:
$ pip3.6 install pygtk
Collecting pygtk
Could not find a version that satisfies the requirement pygtk (from versions: )
No matching distribution found for pygtk
我似乎明白,PyGobject或PyGI取代了Python 3中的pygtk。事实上,ipython3 --matplotlib gtk3
的结果是:
ImportError: Gtk3 backend requires pygobject to be installed.
但是:
$ pip3.6 install pygobject
Collecting pygobject
Could not find a version that satisfies the requirement pygobject (from versions: )
No matching distribution found for pygobject
$ pip3.6 install PyGObject
Collecting PyGObject
Could not find a version that satisfies the requirement PyGObject (from versions: )
No matching distribution found for PyGObject
pip3.6 install PyGI
终于成功了!
但是matplotlib仍然抱怨没有安装GTK。
我还应该尝试什么?
1条答案
按热度按时间vsnjm48y1#
获取Tk后台
正如@ImportanceOfBeingErnest建议的那样,至少应该有一个后端可用:基于TK的
如果在编译python时,Tk开发库可用,这是正确的。但我的情况并非如此(我认为预编译的python发行版应该启用Tk)。
当我尝试使用Tk作为matplotlib后端(
ipython3 --matplotlib tk
)启动ipython时,我得到了类似于以下的错误消息:下面对answer的注解解释了如何在Ubuntu中获取Tk开发库:
apt install tk-dev
。在这样做并重新编译python 3之后。6,
ipython3 --matplotlib tk
会话启动时没有错误,并且可以显示图形。设置默认后端选项
matplotlib documentation给出了一个配置文件的示例,我下载了它作为
~/.config/matplotlib/matplotlibrc
。在该文件中,我设置了backend : TkAgg
。其他后端
上面提到的配置文件中的注解提到了另一个基于WX的GUI后端的存在,与PyGTK和PyQT一样,似乎不能使用pip for python 3进行安装。6截至2017年1月(至少在Linux中):