我用virtualenvwrapper创建了一个virtualenv:
mkvirtualenv test --no-site-packages workon test cdvirtualenv
然后我创建了一个名为testme.py的简单脚本:
#!/usr/bin/env python import pygtk
结果:
$ python testme.py Traceback (most recent call last): File "testme.py", line 3, in <module> import pygtk ImportError: No module named pygtk
我现在尝试了很多次,不同的方式,但没有任何效果......
以下是我已经完成的事情:
Command "python setup.py egg_info" failed with error code 1
在virtualenv(https://pypi.python.org/pypi/ruamel.venvgtk/0.4.1)中安装ruamel.venvgtk
直接链接(并添加路径):
mkdir -p lib/python2.7/dist-packages/ ln -s /usr/lib/python2.7/dist-packages/gtk-2.0 lib/python2.7/dist-packages/ ln -s /usr/lib/python2.7/dist-packages/gobject lib/python2.7/dist-packages/ ln -s /usr/lib/python2.7/dist-packages/glib lib/python2.7/dist-packages/ ln -s /usr/lib/python2.7/dist-packages/cairo lib/python2.7/dist-packages/ add2virtualenv lib/python2.7/dist-packages/
ln -s /usr/lib/python2.7/dist-packages/gtk-2.0 lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/gobject lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/glib lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/cairo lib/python2.7/site-packages/
我现在试了很多次。可以让它运行一次,但无法重现它。
编辑:我忘了链接pygtk本身。
ln -s /usr/lib/python2.7/dist-packages/pygtk.py LIB / python2.7 /站点包/
答案 0 :(得分:2)
这就是我现在的工作方式:
mkvirtualenv test --no-site-packages workon test cdvirtualenv ln -s /usr/lib/python2.7/dist-packages/gtk-2.0 lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/gobject lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/glib lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/cairo lib/python2.7/site-packages/ ln -s /usr/lib/python2.7/dist-packages/pygtk.py lib/python2.7/site-packages/
答案 1 :(得分:0)
您可以使用virtualenv
内的系统包,使用mkvirtualenv environment --system-site-packages