4

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.

Bite code
  • 578,959
  • 113
  • 301
  • 329
  • does your version of virtualenv have `--system-site-packages`. `--no-site-packages` is obsolete. – jfs Aug 05 '12 at 09:25
  • Thanks J.F. That was the problem. You should write it as an answer so I can upvote you. – Bite code Aug 05 '12 at 09:29

2 Answers2

4

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.

0

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.

utapyngo
  • 6,946
  • 3
  • 44
  • 65