When I run gnome-terminal, I get the following error:
当我运行gnome-terminal时,我收到以下错误:
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 odd to me, because the script is located in a python 3.4 installation but is calling print as if it was a python2 script (which is why the error occurs).
这看起来很奇怪,因为脚本位于python 3.4安装中,但是调用print就好像它是一个python2脚本(这就是出错的原因)。
I tried to reinstall the package gi with pip3, but it keeps installing this version that looks like a python2 script.
我试图用pip3重新安装包gi,但它继续安装这个看起来像python2脚本的版本。
My gnome-terminal points to /usr/bin/gnome-terminal, which is a python script that starts with #!/usr/bin/python3.
我的gnome-terminal指向/ usr / bin / gnome-terminal,这是一个以#!/ usr / bin / python3开头的python脚本。
The lines with that particular error in init.py are:
init.py中具有该特定错误的行是:
if __name__ == '__main__':
try:
url = save_file()
print url
except GistError as e:
print e.value
This suggests a quick fix: putting parenthesis in those two print 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.
这很奇怪。
This must be running on /usr/bin/python3, because that's what on the shebang on /usr/bin/gnome-terminal.
这必须在/ usr / bin / python3上运行,因为这就是/ usr / bin / gnome-terminal上的shebang。
python3 on the /usr/bin is actually a link to python3.4, which is a binary file.
/ usr / bin上的python3实际上是python3.4的链接,它是一个二进制文件。
I then run pip3 install gi and I get the following output, which tells me that actually gi is installed.
然后我运行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)
And right now I am out of ideas.
现在我没有想法。
This started after I tried to install a Pumubuntu from https://github.com/Pumubuntu/Pumubuntu.
这是在我尝试从https://github.com/Pumubuntu/Pumubuntu安装Pumubuntu之后开始的。
In the main script file it says:
在主脚本文件中,它说:
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.')
So I thought I had to enter those commands. And that must have broken my gir installation (gir).
所以我以为我必须输入这些命令。这肯定打破了我的gir装置(gir)。
Can anybody help me?
有谁能够帮助我?
3 个解决方案
#1
8
Another way to fix this error that I found was to modify the gnome-terminal
script located in /usr/bin/
and changing the environment (first line of the script) from #!/usr/bin/python3
to #!/usr/bin/python
to switch from Python 3 to Python 2 as the Github command line is for Python 2 as noted in the previous answer.
修复此错误的另一种方法是修改位于/ usr / bin /中的gnome-terminal脚本并将环境(脚本的第一行)从#!/ usr / bin / python3更改为#!/ usr / bin / python从Python 3切换到Python 2,因为Github命令行用于Python 2,如上一个答案中所述。
Therefore, open up xterm
by pushing the Super key (Key beside the bottom left Alt key) or by pushing Alt + F2 and typing in xterm
to search for an alternative terminal and clicking on it to run. Next, type in sudo gedit /usr/bin/gnome-terminal
, push ENTER and edit the first line in accordance to above. It's not the best solution as you shouldn't have to edit the script but it worked for me and it didn't require uninstalling anything.
因此,通过按下超级键(左下方Alt键旁边的键)或按Alt + F2并键入xterm来搜索备用终端并单击它以运行来打开xterm。接下来,输入sudo gedit / usr / bin / gnome-terminal,按ENTER键并按照上述编辑第一行。它不是最好的解决方案,因为你不应该编辑脚本但它对我有用,它不需要卸载任何东西。
Update
The most current build of this requires Python 3, so as Jon M. in his comments stated, change the first line of the file to use Python 3.5:
最新版本需要Python 3,因此Jon M.在他的评论中指出,更改文件的第一行以使用Python 3.5:
#!/usr/bin/python3.5
#2
6
This is an old question but this being the first google hit, it should be answered.
这是一个老问题,但这是第一个谷歌热门,它应该得到回答。
The error is caused by installing gi package on python3.
It is a package for GIST Github commandline for python2. It is not related to gnome object or gnome introspection. Visit it here: python gi on package index
该错误是由python3上安装gi包引起的。它是python2的GIST Github命令行的一个包。它与gnome对象或gnome内省无关。请访问:python gi on package index
It causes naming conflicts with gi.repository, rather than looking for gir in your python dist-packages, your system __init__
the gi package. And hence the error shows
它导致与gi.repository的命名冲突,而不是在你的python dist-packages中寻找gir,你的系统__init__是gi包。因此错误显示
ImportError: No module named 'gi.repository'
ImportError:没有名为'gi.repository'的模块
Uninstalling that package will resolve the error. Also if you are looking for a gister, try defunkt gist
卸载该程序包将解决该错误。如果你正在寻找一个大人物,试试defunkt要点
#3
2
In Python 3.5, I do this:
在Python 3.5中,我这样做:
sudo vim /usr/bin/gnome-terminal
- Modify the first line from
#!/usr/bin/python
to#!/usr/bin/python3.5
sudo vim / usr / bin / gnome-terminal
将#!/ usr / bin / python中的第一行修改为#!/ usr / bin / python3.5
This fixed my problem!
这解决了我的问题!
#1
8
Another way to fix this error that I found was to modify the gnome-terminal
script located in /usr/bin/
and changing the environment (first line of the script) from #!/usr/bin/python3
to #!/usr/bin/python
to switch from Python 3 to Python 2 as the Github command line is for Python 2 as noted in the previous answer.
修复此错误的另一种方法是修改位于/ usr / bin /中的gnome-terminal脚本并将环境(脚本的第一行)从#!/ usr / bin / python3更改为#!/ usr / bin / python从Python 3切换到Python 2,因为Github命令行用于Python 2,如上一个答案中所述。
Therefore, open up xterm
by pushing the Super key (Key beside the bottom left Alt key) or by pushing Alt + F2 and typing in xterm
to search for an alternative terminal and clicking on it to run. Next, type in sudo gedit /usr/bin/gnome-terminal
, push ENTER and edit the first line in accordance to above. It's not the best solution as you shouldn't have to edit the script but it worked for me and it didn't require uninstalling anything.
因此,通过按下超级键(左下方Alt键旁边的键)或按Alt + F2并键入xterm来搜索备用终端并单击它以运行来打开xterm。接下来,输入sudo gedit / usr / bin / gnome-terminal,按ENTER键并按照上述编辑第一行。它不是最好的解决方案,因为你不应该编辑脚本但它对我有用,它不需要卸载任何东西。
Update
The most current build of this requires Python 3, so as Jon M. in his comments stated, change the first line of the file to use Python 3.5:
最新版本需要Python 3,因此Jon M.在他的评论中指出,更改文件的第一行以使用Python 3.5:
#!/usr/bin/python3.5
#2
6
This is an old question but this being the first google hit, it should be answered.
这是一个老问题,但这是第一个谷歌热门,它应该得到回答。
The error is caused by installing gi package on python3.
It is a package for GIST Github commandline for python2. It is not related to gnome object or gnome introspection. Visit it here: python gi on package index
该错误是由python3上安装gi包引起的。它是python2的GIST Github命令行的一个包。它与gnome对象或gnome内省无关。请访问:python gi on package index
It causes naming conflicts with gi.repository, rather than looking for gir in your python dist-packages, your system __init__
the gi package. And hence the error shows
它导致与gi.repository的命名冲突,而不是在你的python dist-packages中寻找gir,你的系统__init__是gi包。因此错误显示
ImportError: No module named 'gi.repository'
ImportError:没有名为'gi.repository'的模块
Uninstalling that package will resolve the error. Also if you are looking for a gister, try defunkt gist
卸载该程序包将解决该错误。如果你正在寻找一个大人物,试试defunkt要点
#3
2
In Python 3.5, I do this:
在Python 3.5中,我这样做:
sudo vim /usr/bin/gnome-terminal
- Modify the first line from
#!/usr/bin/python
to#!/usr/bin/python3.5
sudo vim / usr / bin / gnome-terminal
将#!/ usr / bin / python中的第一行修改为#!/ usr / bin / python3.5
This fixed my problem!
这解决了我的问题!