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.
What’s the best way to do this? Or should I just suck it up and drop the –no-site-packages option?
Advertisement
Answer
JavaScript
x
12
12
1
$ virtualenv --no-site-packages --python=/usr/bin/python2.6 myvirtualenv
2
$ cd myvirtualenv
3
$ source bin/activate
4
$ cd lib/python2.6/
5
$ ln -s /usr/lib/pymodules/python2.6/gtk-2.0/
6
$ ln -s /usr/lib/pymodules/python2.6/pygtk.pth
7
$ ln -s /usr/lib/pymodules/python2.6/pygtk.py
8
$ ln -s /usr/lib/pymodules/python2.6/cairo/
9
$ python
10
>>> import pygtk
11
>>> import gtk
12