Search code examples
pythonubuntupygtkvirtualenv

Virtualenv on Ubuntu with 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.

What's the best way to do this? Or should I just suck it up and drop the --no-site-packages option?


Solution

  • $ 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