Question

I installed the package python-gconf on Ubuntu 12.04 and played with it: it's a python binding to the gnome configuration tool, and there is no pypi package for it.

As soon as I created a virtualenv (without --no-site-packages), any attempt to import gconf would lead to ImportError.

The gconf module works fine at the system level, but not in the virtual env. I investigated, and opening python-gconf.deb teached me that it's just a gconf.so binary.

Searching for it tells me it's been installed in /home/lib/python2.7/dist-packages/gtk-2.0/gconf.so

I did try to force Python hands:

sudo ln -s /usr/lib/python2.7/dist-packages/gtk-2.0/gconf.so ~/.virtualenvs/appetizer/lib/python2.7/site-packages/

But it only resulted in:

>>> import gconf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: could not import gobject (error was: 'No module named gobject')

So I'm guessing it's very dependant to GTK.

Was it helpful?

Solution

You should create your virtualenv using --system-site-packages option to make all system packages visible. Symlinking external packages into virtualenv's structure also works for most situations when you need only one external package.

OTHER TIPS

If you have already created your virtual environment, just remove the no-global-site-packages.txt file from it to make it see system packages.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top