Python 3 找不到“gi”模块

Python 3 找不到“gi”模块

当我尝试运行 时,这个问题就开始出现了redshift-gtk。我手动安装了该程序,它通过 就可以正常运行redshift,但我希望它与指示器一起运行。我总是得到以下输出:

Traceback (most recent call last):
File "/usr/local/bin/redshift-gtk", line 26, in <module>
from redshift_gtk.statusicon import run
File "/usr/local/lib/python3.8/site-packages/redshift_gtk/statusicon.py", line 30, in <module>
import gi
ModuleNotFoundError: No module named 'gi'

我确实认为这是一个普遍问题,而不是红移特有的问题。我已经安装了必要的先决条件:

python3-gi is already the newest version (3.36.0-1)
python3-gi-cairo is already the newest version (3.36.0-1).
gir1.2-gtk-3.0 is already the newest version (3.24.20-0ubuntu1)

我尝试执行locate python3-gi,结果如下:

/snap/gnome-3-28-1804/128/usr/share/doc/python3-gi
/snap/gnome-3-28-1804/128/usr/share/doc/python3-gi-cairo
/snap/gnome-3-28-1804/128/usr/share/doc/python3-gi/changelog.Debian.gz
/snap/gnome-3-28-1804/128/usr/share/doc/python3-gi/copyright
/snap/gnome-3-28-1804/128/usr/share/doc/python3-gi-cairo/copyright
/usr/share/doc/python3-gi
/usr/share/doc/python3-gi-cairo
/usr/share/doc/python3-gi/changelog.Debian.gz
/usr/share/doc/python3-gi/copyright
/usr/share/doc/python3-gi-cairo/changelog.Debian.gz
/usr/share/doc/python3-gi-cairo/copyright
/var/lib/dpkg/info/python3-gi-cairo.list
/var/lib/dpkg/info/python3-gi-cairo.md5sums
/var/lib/dpkg/info/python3-gi.list
/var/lib/dpkg/info/python3-gi.md5sums
/var/lib/dpkg/info/python3-gi.postinst
/var/lib/dpkg/info/python3-gi.prerm

所以我不知道为什么会出现“没有名为‘gi’的模块”错误。我还安装了 python-gobject:

python-gobject is already the newest version (3.34.0+2.28.6-14ubuntu1)

这是我现在的 Linux 版本:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:    20.04
Codename:   focal

这可能是什么问题?

答案1

首先你应该知道 RedShift 被打包在所有 Ubuntu 版本

要删除本地安装的内容,请使用:

sudo python3.8 -m pip uninstall redshift-gtk
sudo rm /usr/local/bin/redshift
sudo rm /usr/local/bin/redshift-gtk

因此,你可以简单地从存储库安装 RedShift:

sudo apt-get install redshift redshift-gtk

相关内容