installing PyGObject via pip in virtualenv [duplicate]
Asked Answered
S

1

12

I'm actually upgrading an old django app from python2.7 to python3.4. While installing pygobject via pip, I got this error:

Collecting pygobject
  Using cached pygobject-2.28.3.tar.bz2
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/tmp/pip-build-9dp0wn96/pygobject/setup.py", line 272
        raise SystemExit, 'ERROR: Nothing to do, gio could not be found and is essential.'
                    ^
    SyntaxError: invalid syntax

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-9dp0wn96/pygobject

I am trying to install it in a virtualenv. System-wide installation doesn't work either... I am working on arch linux with python3.4

I have installed the arch package named pygobject-devel 3.16.2-1 but I still can't import gobject python module

What is this damned missing gio?

Any help is welcomed... Thanx in advance !

Selfsufficient answered 9/7, 2015 at 17:31 Comment(4)
It could be that you only need to install gi, but I am not sure about it and can't install PyGObject in my virtualenv either.Within
Ok,j I managed to install pyGObject, system-wide with a pre-compiled package, which is the easier way (extra/python-gobject2). The upper error is a simple Syntax error, because setup.py for this pip package is only designed for Windows anyway... I have to run some tests and experiment to manage to use it in virtualenv.Selfsufficient
According to the answer here this is now possible. I did not check this myself.Idou
@KlaasvanSchelven You're right ! Thank you !Selfsufficient
S
7

ANSWER IS NOW IN THE POST TAGGED IN COMMENT ABOVE !!!! Have a look there => Python cannot install PyGObject

Ok I just managed it !

To install PyGObject in virtrualenv, give up with pip.

  1. Install PyGObject system-wide (with your package manager or compile it manually). For example, in my case :

    sudo pacman -Suy python-gobject2
    
  2. Link it in your virtualenv :

    ln -s /usr/lib/python3.4/site-packages/gobject* /WHEREVER/IS/YOUR/VIRTUALENV/venv/lib/python3.4/site-packages/
    
  3. You might need to link some other modules (in my case glib) :

    ln -s /usr/lib/python3.4/site-packages/glib* /WHEREVER/IS/YOUR/VIRTUALENV/venv/lib/python3.4/site-packages/
    

You might find some helpful infos about system-wide and virtualenv installations and interactions between modules here :

virtualenv: Specifing which packages to use system-wide vs local

Selfsufficient answered 24/7, 2015 at 11:44 Comment(2)
I've made vext to automate this. If you have pygobject installed in the system then you can install vext.gi in the virtualenv.Haematoxylin
Thx @StuartAxon, vext is a great lil' helper.Mahalia

© 2022 - 2024 — McMap. All rights reserved.