python - 如何在 virtualenv 中安装 pygtk?

标签 python gtk ipython

我在虚拟环境(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

最佳答案

由于您正在运行基于 Debian 的发行版;您可以省去一些麻烦,只需sudo apt-get install ipython(如果您想使用Python 3,则sudo apt-get install ipython3)。

这将确保安装正确的 GTK 绑定(bind)。这是最受支持的方式

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

关于python - 如何在 virtualenv 中安装 pygtk?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13782776/

相关文章:

rust - 在 GTK4 中制作可点击框

python - GTK 和 PYGTK 的区别

python - SPYDER 和 IPython 4.0 支持

python - IPython 错误行和列

python - 如何避免在源代码中保留版本号?

python - 减去 ndarray 的最后一个轴

python - 如何在向后兼容的代码中使用 GLib.io_add_watch ?

python - 如何切片 numpy 数组的一个子集

Python:子串存在

python - 使用来自 ipywidgets 的交互与数据框