没有站点包的 Ubuntu 上的 Virtualenv [英] Virtualenv on Ubuntu with no site-packages
问题描述
我最近在用 python 开发时一直在使用 virtualenv.我喜欢使用 --no-site-packages 选项的隔离开发环境的想法,但是在开发 PyGTK 应用程序时这样做可能有点棘手.PyGTK 模块默认安装在 Ubuntu 上,我想让 virtualenv(使用 --no-site-packages)知道位于系统其他地方的特定模块.
I've been using virtualenv lately while developing in python. I like the idea of a segregated development environment using the --no-site-packages option, but doing this while developing a PyGTK app can be a bit tricky. The PyGTK modules are installed on Ubuntu by default, and I would like to make a virtualenv (with --no-site-packages) aware of specific modules that are located elsewhere on the system.
这样做的最佳方法是什么?或者我应该把它吸干并放弃 --no-site-packages 选项?
What's the best way to do this? Or should I just suck it up and drop the --no-site-packages option?
推荐答案
$ 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/
$ ln -s /usr/lib/pymodules/python2.6/pygtk.pth
$ ln -s /usr/lib/pymodules/python2.6/pygtk.py
$ ln -s /usr/lib/pymodules/python2.6/cairo/
$ python
>>> import pygtk
>>> import gtk
这篇关于没有站点包的 Ubuntu 上的 Virtualenv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!