ValueError:命名空间 Gtk 不可用

2024-02-18

按照说明进行操作时2. 入门 — Python GTK+ 3 教程 3.4 文档 https://python-gtk-3-tutorial.readthedocs.io/en/latest/introduction.html

Tries

In [6]: import gi
   ...: gi.require_version('Gtk', '3.0')
   ...: from gi.repository import Gtk

它报告错误:

~/anaconda3/lib/python3.7/site-packages/gi/__init__.py in require_version(namespace, version)
    128     available_versions = repository.enumerate_versions(namespace)
    129     if not available_versions:
--> 130         raise ValueError('Namespace %s not available' % namespace)
    131
    132     if version not in available_versions:

ValueError: Namespace Gtk not available

Follow 如何安装 GTK+ 3.0? - 询问Ubuntu https://askubuntu.com/questions/101306/how-do-i-install-gtk-3-0并安装Gtk到ubuntu

sudo apt-get install libgtk-3-dev

但是,它仍然报告相同的错误。

如何解决我的问题?

Note:

尝试了解决方案

me@host:~:
$ sudo apt install python3-gi gobject-introspection gir1.2-gtk-3.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gir1.2-gtk-3.0 is already the newest version (3.24.8-1ubuntu1).
gobject-introspection is already the newest version (1.60.1-1).
python3-gi is already the newest version (3.32.0-1).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
me@host:~:
$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> gi.require_version('Gtk', '3.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/me/anaconda3/lib/python3.7/site-packages/gi/__init__.py", line 130, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available

安装其他

me@host:~:
$ sudo apt install -y gir1.2-gtk-3.0
Reading package lists... Done
Building dependency tree       
Reading state information... Done
gir1.2-gtk-3.0 is already the newest version (3.24.8-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.
me@host~:
$ ipython
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
Type 'copyright', 'credits' or 'license' for more information
IPython 7.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]:  import gi                                                                                                        

In [2]: gi.require_version('Gtk', '3.0')                                                                                  
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-3fc173a88e42> in <module>
----> 1 gi.require_version('Gtk', '3.0')

~/anaconda3/lib/python3.7/site-packages/gi/__init__.py in require_version(namespace, version)
    128     available_versions = repository.enumerate_versions(namespace)
    129     if not available_versions:
--> 130         raise ValueError('Namespace %s not available' % namespace)
    131 
    132     if version not in available_versions:

ValueError: Namespace Gtk not available

它不起作用,

我的机器:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 19.04
Release:    19.04
Codename:   disco

我在ubuntu上安装dropbox时遇到问题

$ dropbox start
Starting Dropbox...
The Dropbox daemon is not installed!
Run "dropbox start -i" to install the daemon

运行“dropbox start -i”

$ dropbox start -i
Starting Dropbox...Traceback (most recent call last):
  File "/usr/bin/dropbox", line 1443, in start
    download()
  File "/usr/bin/dropbox", line 295, in download
    gi.require_version('Gdk', '3.0')
  File "/home/gaowei/anaconda3/lib/python3.7/site-packages/gi/__init__.py", line 130, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gdk not available

你需要安装gobject-内省 https://packages.ubuntu.com/xenial/gobject-introspection, python3-gi https://packages.ubuntu.com/xenial/python3-gi and gir1.2-gtk-3.0 https://packages.ubuntu.com/disco/gir1.2-gtk-3.0,这些包包含将 GTK+ 库公开给 python3 的文件。

sudo apt install python3-gi gobject-introspection gir1.2-gtk-3.0

对于 CENTOS (7)/OpenSUSE (15.1),您必须替换该软件包gir1.2-gtk-3.0 with gtk3-devel分别在 dnf/yum/zypper 中 - 谢谢bgStack https://stackoverflow.com/users/3569534/bgstack15.

root@oz123:/home/oz123# python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> gi.require_version('Gtk', '3.0')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/gi/__init__.py", line 130, in require_version
    raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Gtk not available
>>> 
root@oz123:/home/oz123# apt install -y gir1.2-gtk-3.0
root@oz123:/home/oz123# python3
Python 3.6.8 (default, Jan 14 2019, 11:02:34) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gi
>>> gi.require_version('Gtk', '3.0')
>>> 

边注

称为的包xyz-devdebian\ubuntu 中包含 C 头文件、pkg-config 文件和 autotools 宏。仅当您打算使用 C 和 C++ 等编译语言构建软件时才需要这些。 这些全部安装到:

/usr/include/../xyz/header1.h  # headers
/usr/include/../xyz/header2.h
...
/usr/lib/x86_64-linux-gnu/pkgconfig/libxyz.pc  # pkgconfig files
...
/usr/share/aclocal/xyz.m4  # autotools macros

Use dpkg -L libgtk-3-dev查看此软件包在您的系统上安装的所有文件。

update

请删除保管箱dpkg -r dropbox然后使用以下命令重新安装

root@yeni2:/# dpkg -i dropbox_2019.02.14_amd64.deb 
Selecting previously unselected package dropbox.
(Reading database ... 126384 files and directories currently installed.)
Preparing to unpack dropbox_2019.02.14_amd64.deb ...
Unpacking dropbox (2019.02.14) ...
dpkg: dependency problems prevent configuration of dropbox:
 dropbox depends on libpango1.0-0 (>= 1.36.3); however:
  Package libpango1.0-0 is not installed.

dpkg: error processing package dropbox (--install):
 dependency problems - leaving unconfigured
Processing triggers for man-db (2.8.3-2) ...
Processing triggers for gnome-menus (3.13.3-11ubuntu1) ...
Processing triggers for desktop-file-utils (0.23-1ubuntu3) ...
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for hicolor-icon-theme (0.17-2) ...
Errors were encountered while processing:
 dropbox

现在,如果缺少依赖项,请使用以下方法修复它们:

root@yeni2:/# apt install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libpango1.0-0 libpangox-1.0-0
The following NEW packages will be installed:
  libpango1.0-0 libpangox-1.0-0
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 45.0 kB of archives.
After this operation, 203 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://de.archive.ubuntu.com/ubuntu bionic/universe amd64 libpangox-1.0-0 amd64 0.0.2-5 [41.7 kB]
Get:2 http://de.archive.ubuntu.com/ubuntu bionic/universe amd64 libpango1.0-0 amd64 1.40.14-1 [3,332 B]
Fetched 45.0 kB in 0s (264 kB/s)    
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libpangox-1.0-0:amd64.
(Reading database ... 126411 files and directories currently installed.)
Preparing to unpack .../libpangox-1.0-0_0.0.2-5_amd64.deb ...
Unpacking libpangox-1.0-0:amd64 (0.0.2-5) ...
Selecting previously unselected package libpango1.0-0:amd64.
Preparing to unpack .../libpango1.0-0_1.40.14-1_amd64.deb ...
Unpacking libpango1.0-0:amd64 (1.40.14-1) ...
Setting up libpangox-1.0-0:amd64 (0.0.2-5) ...
Setting up libpango1.0-0:amd64 (1.40.14-1) ...
Setting up dropbox (2019.02.14) ...
Please restart all running instances of Nautilus, or you will experience problems. i.e. nautilus --quit
Dropbox installation successfully completed! You can start Dropbox from your applications menu.
Processing triggers for libc-bin (2.27-3ubuntu1) ...
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ValueError:命名空间 Gtk 不可用 的相关文章

  • 我们可以在 Bash 脚本中使用 PHP 吗?

    我有一个 bash 脚本abcd sh bin sh for i in seq 8 do ssh w i uptime ps elf grep httpd wc l free m mpstat done pid sleep 1 kill 9
  • = 上的语法无效? [关闭]

    Closed 这个问题是无法重现或由拼写错误引起 help closed questions 目前不接受答案 我是 python 的初学者 试图使用 yes no 来制作一个非常简单的程序 它表示该行中的第一个 存在语法错误 if monk
  • 如何跨多个文本文件查找字典中键的频率?

    我应该计算文档 individual articles 中所有文件中字典 d 的所有键值的频率 这里 文档 individual articles 大约有20000个txt文件 文件名为1 2 3 4 例如 假设 d Britain 5 7
  • 在 python 中指定文件夹位置时使用 / 和 \\ 有什么区别?

    我在 Windows 10 上使用 python v3 6 当指定字符串来表示目录位置时 下面的 2 种方法有什么区别 folder location C Users username Dropbox Inv folder location
  • ValueError:超出整数字符串转换的限制(4300)

    gt gt gt import sys gt gt gt sys set int max str digits 4300 Illustrative this is the default gt gt gt int 2 5432 Traceb
  • 复制单元格包含多条数据的行

    我想获取一个数据框并复制某些行 一列 称为name 可能有多个名称 下面构建了一个示例数据框 data Joe 17 11 2018 2 Karen 17 11 2018 4 Bill Avery 17 11 2018 6 Sam 18 1
  • 如何从 python 获取 BQL (bLOOMBERG) 查询

    我在 Excel 中使用 BQL 有以下查询 BQL MEMBERS INEMCBI LX Equity type holdings 名称 列 2 行 223 这显示了特定共同基金的证券表 像这样 在此输入图像描述 https i stac
  • 早于 0.4.12 的 Node.js 无法在 AWS EC2 上正常工作。为什么?

    我无法在 AWS EC2 Ubuntu 或 CentOs 没关系 上安装 node js v0 6 1 安装后我输入node 处理器负载达到100 但 v0 4 12 工作正常 可能只有我有这个问题 那不好意思了 请告诉我我做错了什么 提前
  • 如何在 Windows 上使用 Python 3.6 来安装 Python 2.7

    我想问一下如何使用pip install对于 Python 2 7 当我之前安装并使用 Python 3 6 时 我现在必须使用 Windows 上的 Python 版本 pip install 继续安装 Python 3 6 我需要使用以
  • 如何获取 bash 中从 Ping 接收到的数据包的百分比?

    当 ping 主机时 我希望输出仅显示收到的数据包 已发送 5 个 的百分比 我想我需要使用grep不知怎的 但我不知道如何 我是 bash 编程的新手 这是我所在的地方 ping c 5 q host grep grep 中应该包含什么
  • 为什么延迟参数会影响预测曲线?

    I put the result of Gekko s calculation into the queue after a delay write the first value of the queue to TCLab Arduino
  • X 服务器使用什么像素格式?

    X 服务器使用什么像素格式 RGBA ARBG BGRA 如果有任何特定格式的话 Update 我专门寻找有关颜色分量顺序和位模式的信息 你的意思是帧缓冲区格式 或者所有支持的像素图格式 无论是哪一种 都取决于您的图形硬件 驱动程序和配置
  • Python 中“0 is 0”总是“True”吗?

    Python 3 8 或 CPython 3 8 添加了警告 SyntaxWarning is with a literal Did you mean 对于代码0 is 0 我理解该警告 并且我知道两者之间的区别is and 但是 我也知道
  • 从sourceforge下载最新版本

    我正在尝试在 bash 脚本中从 Sourceforge 下载最新版本的graphicsmagick wget q https sourceforge net projects graphicsmagick files latest dow
  • 在哪里可以找到所有 C 标准库的源代码?

    我正在寻找所有 C 标准库的完整源代码 也就是说 我正在寻找 stdio h stdlib h string h math h 等的源代码 我想看看它们是如何创建的 我认为这取决于不同的平台 但 Linux 或 Windows 都会受到欢迎
  • ubuntu 中的 echo -e 选项不起作用

    我的同事使用Ubuntu 我使用openSUSE 我们使用相同的makefile编译相同的源代码 我的环境运行良好 但我的同事不能 总是输出无法识别 e选项 我们检查makefile 只发现echo命令使用 e option Ubuntu的
  • 如何在 Linux 中显示进程状态(阻塞、非阻塞)

    有没有办法查询 Linux 进程表中进程的状态 以便能够演示执行查询时进程是正在运行还是被阻止 我的目标是从进程或程序的 外部 执行此操作 因为我希望从操作系统进程的角度来理解这一点 但欢迎任何想法 这是Python代码阻塞的过程 impo
  • 如何将时间间隔划分为不同长度的部分?

    我有一个从 0 到t 我想把这个区间分成一个以2 25 2 25 1 5为周期的累积序列 方法如下 input start 0 stop 19 output sequence 0 2 25 4 5 6 8 25 10 5 12 14 25
  • Linux shell 标题大小写

    我正在编写一个 shell 脚本并有一个如下所示的变量 something that is hyphenated 我需要在脚本中的各个点使用它 如下所示 something that is hyphenated somethingthati
  • 连接运算符 + 或 ,

    var1 abc var2 xyz print literal var1 var2 literalabcxyz print literal var1 var2 literal abc xyz 除了带有 的自动空格之外 两者有什么区别 哪个通

随机推荐