Python:virtualenv - gtk-2.0 [英] Python: virtualenv - gtk-2.0

查看:24
本文介绍了Python:virtualenv - gtk-2.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要将 gtk-2.0 添加到我的 virtualenv,我执行了以下操作:

To add gtk-2.0 to my virtualenv I did the following:

$ virtualenv --no-site-packages --python=/usr/bin/python2.6 myvirtualenv
$ cd myvirtualenv
$ source bin/activate
$ cd lib/python2.6/
$ ln -s /usr/lib/pymodules/python2.6/gtk-2.0/ 

没有站点包的Ubuntu上的Virtualenv

现在在 Python 解释器中,当我导入 gtk 时,它说:没有名为 gtk 的模块.当我用 sudo 启动解释器时,它就起作用了.

Now in the Python interpreter when I do import gtk it says: No module named gtk. When I start the interpreter with sudo it works.

我需要使用 sudo 的任何原因,有没有办法防止它?

Any reason why I need to use sudo and is there a way to prevent it?

更新:
忘了提到 cairo 和 pygtk 的工作,但它不是我需要的.

Update:
Forgot to mention that cairo and pygtk work but it's not the one I need.

更新 2:
这里的目录表明我没有疯.http://www.friendly-stranger.com/pictures/symlink.jpg

推荐答案

sudo python 导入它就好了,因为那个解释器没有使用你的虚拟环境.所以不要那样做.

sudo python imports it just fine because that interpreter isn't using your virtual environment. So don't do that.

您只链接了一项必要的项目.也做您链接的问题的答案中提到的其他人.

You only linked in one of the necessary items. Do the others mentioned in the answer to the question you linked as well.

(pygtk.pth 文件特别重要,因为它告诉 python 将您链接的目录实际放到 python 路径上)

(The pygtk.pth file is of particular importance, since it tells python to actually put that directory you linked onto the python path)

把这些东西放在 $VIRTUALENV/lib/python2.6/site-packages/ 而不是上面的目录.

Put that stuff in $VIRTUALENV/lib/python2.6/site-packages/ rather than the directory above that.

看起来 .pth 文件不是从该目录中读取的 - 只是从站点包中读取

Looks like the .pth files aren't read from that directory - just from site-packages

这篇关于Python:virtualenv - gtk-2.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆