2

我在虚拟环境(1.13 和 2.7.2)中安装了 ipython 并尝试ipython -gui=gtk了但仍然获得了基本的终端界面,例如没有 %paste 支持。

现在我尝试安装 pygtk 但也没有成功。

我正在使用 OpenBox WM 运行 Crunchbang linux。

    [TerminalIPythonApp] GUI event loop or pylab initialization failed
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
...python2.7/local/lib/python2.7/site-packages/IPython/lib/inputhook.pyc in enable_gui(gui, app)
    526         e = "Invalid GUI request %r, valid ones are:%s" % (gui, guis.keys())
    527         raise ValueError(e)
--> 528     return gui_hook(app)
    529 

...python2.7/local/lib/python2.7/site-packages/IPython/lib/inputhook.pyc in enable_gtk(self, app)
    286         IPython.
    287         """
--> 288         import gtk
    289         try:
    290             gtk.set_interactive(True)

ImportError: No module named gtk

我试图在我激活的 virtualenv 中 pip install pygtk 但没有运气。

完整日志:

$ pip install pygtk
Downloading/unpacking pygtk
  Downloading pygtk-2.24.0.tar.bz2 (2.4MB): 2.4MB downloaded
  Running setup.py egg_info for package pygtk
    ********************************************************************
    * Building PyGTK using distutils is only supported on windows. *
    * To build PyGTK in a supported way, read the INSTALL file.    *
    ********************************************************************
    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 ...python2.7/build/pygtk
4

2 回答 2

2

由于您正在运行基于 debian 的发行版;您可以简单地省去一些麻烦sudo apt-get install ipythonsudo apt-get install ipython3如果您想使用 Python 3)。

这将确保也安装了正确的 GTK 绑定。这是最受支持的方式

最新版本的 ipython 可以自动检测虚拟环境。

于 2012-12-09T15:18:13.147 回答
0

我首先用 pip 安装了 gi(在 ubuntu 上)并得到了同样的错误,没有 virtualenv。我的解决方案是卸载 gi: sudo -H pip uninstall gi 然后安装使用: sudo apt-get install --reinstall python-gi

于 2017-09-25T09:21:08.193 回答