EDIT: If you vote this question to be a duplicate, please do at least take the time to read the question instead of just flagging it a duplicate because it looks somewhat similar to another question. If you would have done that, you would immediately realize that it is not a duplicate. I'm merely trying to show some wider context.
My distro still uses Python 2.6 as python interpreter. Now I want to use a module, which needs Python 2.7. I installed Python 2.7, but it would break other applications. So I set up a virtual environment with Python 2.7 as interpreter:
virtualenv -p ~/pkg/bin/python2.7 venv
If I activate the virtual environment and run python the new interpreter is used. Good! Now I need to import
modules, e.g.
import gtk
This works globally (i.e. in Python 2.6), but not in my virtual environment (i.e. in Python 2.7). I tried to set the sys.path
the same for the virtual environment, but this would give me errors such as
ImportError: /usr/lib64/python2.6/site-packages/gtk-2.0/glib/_glib.so: undefined symbol: PyUnicodeUCS4_DecodeUTF8
which is somewhat expected.
A search with
pip search gtk
would not lead any results either. My best guess right now is that I have to install gtk from source, and compile it against Python 2.7. However, this pulls in other dependencies and going down that hole for about 7 or 8 steps, I resigned.
Is there an easier way to solve this issue?