Gnome terminal does not start due to error in python script related to GI

When I run the gnome terminal, I get the following error:

Traceback (most recent call last):
  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
  File "/usr/local/lib/python3.4/dist-packages/gi/__init__.py", line 39
    print url

This looks strange to me because the script is in a Python 3.4 installation, but calls print as if it were a Python2 script (which is why the error occurs).

I tried reinstalling the gi package with pip3, but it continues to install this version, which looks like a python2 script.

My gnome terminal points to the / usr / bin / gnome terminal, which is a python script that starts with C #! / Usr / bin / python3.

Lines with this particular error in init .py:

if __name__ == '__main__':                                                                                                                                                                                                                                                                                      
         try:                                                                                                                                                                                                                                                                                                    
                 url = save_file()                                                                                                                                                                                                                                                                               
                 print url                                                                                                                                                                                                                                                                                   
         except GistError as e:                                                                                                                                                                                                                                                                                  
                 print e.value     

This offers a quick solution: put the brackets in these two printed lines.

  File "/usr/bin/gnome-terminal", line 9, in <module>
    from gi.repository import GLib, Gio
ImportError: No module named 'gi.repository'

Which is strange.

/usr/bin/python3, /usr/bin/gnome-Terminal.

python3 /usr/bin - python3.4, .

pip3 install gi , , gi .

Requirement already satisfied (use --upgrade to upgrade): gi in /usr/local/lib/python3.4/dist-packages
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/lib/python3/dist-packages (from gi)

.

, Pumubuntu https://github.com/Pumubuntu/Pumubuntu.

:

import sys
if len(sys.argv) == 1:
    print('Importing Python modules. If one is missing get it with:\n'
          '  "sudo apt-get install python-..." or\n'
          '  "sudo apt-get install girX.Y-..." for gi.repository imports.')

, . , , gir (gir).

- ?

+8
5

, , - gnome-terminal script, /usr/bin/, ( script) #!/usr/bin/python3 #!/usr/bin/python Python 3 Python 2 Github Python 2, .

xterm, Super ( Alt) Alt + F2 xterm, . sudo gedit /usr/bin/gnome-terminal, ENTER . , script, , -.

Update

Python 3, Jon M. , Python 3.5:

#!/usr/bin/python3.5
+12

Python 3.5 :

  • sudo vim /usr/bin/gnome-terminal
  • #!/usr/bin/python #!/usr/bin/python3.5

!

+7

, -, .

gi python3.
GIST Github python2. . : python gi ( pygobject)

gi.repository, , gir python, __init__ gi. , ,

ImportError: No module named 'gi.repository'

. , , defunkt gist

+6
source

I also got this problem after upgrading python3.5 to python3.6

This is not the best way, but it works fine.

this problem is due to _gi_cairo. I solved it with the following code

 cd /usr/lib/python3/dist-packages/gi/
 sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
 sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so
+4
source

What happened to me with the script / usr / bin / chrome-gnome-shell on Linux (RHEL 7.6):

Traceback (most recent call last):
Traceback (most recent call last):
  File "/usr/bin/chrome-gnome-shell", line 16, in <module>
    from gi.repository import GLib, Gio
ModuleNotFoundError: No module named 'gi'

To fix this, I had to install PyGObject :

$ sudo yum install python36-gobject.x86_64
# or directly with pip: pip3 install PyGObject

After the installation was completed, running the script showed no errors.

0
source

Source: https://habr.com/ru/post/1607913/


All Articles