After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688353 - PYTHONPATH wrong when using python 3
PYTHONPATH wrong when using python 3
Product: jhbuild
Classification: Infrastructure
Component: general
Other All
: Normal normal
: ---
Assigned To: Jhbuild maintainers
Jhbuild QA
Depends on:
Blocks: python3
Reported: 2012-11-14 21:58 UTC by Craig Keogh
Modified: 2021-05-17 15:55 UTC
See Also:
GNOME target: ---
GNOME version: ---

Description Craig Keogh 2012-11-14 21:58:50 UTC
I'd expect this to work:
# jhbuild run python3 -c "import cairo"

Traceback (most recent call last):
  • File "<string>", line 1
  • File "/opt/gnome/lib64/python2.7/site-packages/cairo/", line 1
    from _cairo import *ImportError: No module named _cairo

PYTHONPATH is wrong.
Comment 1 Craig Keogh 2012-11-14 21:59:51 UTC
Comment from Frederic Peters bug 688062 comment 5:
It would have been much easier if Python 3 had a different environment variable
(looks like that was discussed in <>); actually
I don't know, I have no idea how we're supposed to get both python versions to
behave properly.
Comment 2 Martin Pitt 2012-12-18 08:24:21 UTC
So far I got by with running python3-y stuff in jhbuild with an explicit

  PYTHON=python3 jhbuild run ...

which tells jhbuild to set the correct $PYTHONPATH for the py3 libs. However, as much as a $PYTHON3PATH would have made sense (as in practice python 3 is a different language), I guess it's too late for this now.

I don't really have a good solution for this, as jhbuild cannot know in advance whether you are going to call py2 or py3 (or even both).

The only thing that comes to my mind is a hack:

 * Let jhbuild set up PYTHONPATH for python3, as this will over time become "the" python.
 * Install a "python" and "python2" shell script wrapper alongside the "jhbuild" binary (i. e. in ~/.local/bin) which modifies $PYTHONPATH for python2, and then execs the real python with all arguments.

Does anybody have a better idea?
Comment 3 Paolo Borelli 2013-01-08 13:46:17 UTC
maybe jhbuild could install both "jhpython" and "jhpython3" wrapper scripts that set the PYTHONPATH properly and then export PYTHON=jhpython and PYTHON3=jhpython3
Comment 4 Martin Pitt 2013-01-08 14:36:01 UTC
But usually projects use $PYTHON to determine exactly that -- which python version to run. If that would work, we could just set PYTHON3=python and be done with it. :-)
Comment 5 Martin Pitt 2013-01-08 14:44:25 UTC
> we could just set PYTHON3=python

Err, PYTHON3=python3, of course.
Comment 6 Paolo Borelli 2013-01-08 15:16:47 UTC
(In reply to comment #4)
> But usually projects use $PYTHON to determine exactly that -- which python
> version to run. If that would work, we could just set PYTHON3=python and be
> done with it. :-)

No what I mean is that those wrappers would only be used in "jhbuild run" and not "jhbuild build". So a program with "#!/bin/env python3" would get "jhpython3" as the interpreter and that in turn would set up the right PYTHONPATH
Comment 7 Martin Pitt 2013-01-08 16:29:44 UTC
Ah, but then I think it would be better to have a jhbuild specific python3 wrapper which sets up $PYTHONPATH correctly and calls the real python3. Then we do not require programs to respect $PYTHON.
Comment 8 GNOME Infrastructure Team 2021-05-17 15:55:29 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: