在 mac 中,想使用 gtk 的工具
知道要install gtk , pygtk
(mypython) peicheng@IronMan[~/workarea/openxenmanager]{10:48}
$ python openxenmanager
Traceback (most recent call last):
File "openxenmanager", line 23, in <module>
import gtk
ImportError: No module named gtk
直接使用 pip install 出現,
$ pip install pygtk
Collecting pygtk
Using cached pygtk-2.24.0.tar.bz2
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 /private/var/folders/bn/73_b2959181dz267sk7x5y080000gp/T/pip-build-g0KAka/pygtk/
所以使用 brew install gtk pygtk
(mypython) peicheng@IronMan[~/workarea/openxenmanager]{10:49}
$ brew install gtk
(mypython) peicheng@IronMan[~/workarea/openxenmanager]{10:49}
$ brew install pygtk
(mypython) peicheng@IronMan[~/workarea/openxenmanager]{10:49}
$ python openxenmanager
Traceback (most recent call last):
File "openxenmanager", line 23, in <module>
import gtk
ImportError: No module named gtk
安裝好還是有這個訊息,環境下是有使用 virtaulenv的 brew install 的 packages 在另外一個目錄下,
切到 virtualenv 的 site-packages 的路徑下
cd /Users/peicheng/env/mypython/lib/python2.7/site-packages
ln -s /usr/local/lib/python2.7/site-packages/gtk-2.0 ./gtk-2.0
ln -s /usr/local/lib/python2.7/site-packages/pygtk.pth pygtk.pth
這樣就可以正常使用了