ValueError:命名空间Gtk不可用

原创 287865  2019-07-10 00:06 

按照说明 2。入门?? python gtk + 3教程3.4文档

尝试

   in [6]: import gi
   ...: gi.require_version('gtk', '3.0')
   ...: from gi.repository import gtk
   

它报告错误:

[123 ]

   ~/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
   

按照

我如何安装gtk + 3.0? - 询问ubuntu 并安装gtk到ubuntu

   sudo apt-get install libgtk-3-dev
   

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

如何解决我的问题是什么?

注意:

试图解决

   [email protected]:~:
$ 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.
[email protected]:~:
$ 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
   

安装其他

   [email protected]:~:
$ 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.
[email protected]~:
$ 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
   

安装Dropbox到ubuntu时遇到问题

   $ dropbox start
starting dropbox...
the dropbox daemon is not installed!
run "dropbox start -i" to install the daemon
   

运行“dropbox start -i”

  [ 123]  $ 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-introspection

python3-gi gir1.2-gtk-3.0 ,这些包包含将gtk + libs暴露给python3的文件。

   sudo apt install python3-gi gobject-introspection gir1.2-gtk-3.0
   
   [email protected]:/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
>>> 
[email protected]:/home/oz123# apt install -y gir1.2-gtk-3.0
[email protected]:/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')
>>> 

   side-note 

在debian \ ubuntu中打包calles

包含c头文件,pkg-config文件和autotools宏。只有当你打算使用c和c ++这样的编译语言构建软件时才需要这些。这些都安装到: xyz-dev

   /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
  使用

查看您的系统上此软件包安装的所有文件。 dpkg -l libgtk-3-dev 更新

请删除

的Dropbox,然后重新安装以下内容命令 dpkg -r dropbox

   [email protected]:/# 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
  现在,如果缺少依赖关系,则修正它们:

   [email protected]:/# 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) ...
  

本文地址:https://www.hedasudi.com/2824.shtml
版权声明:本文为原创文章,版权归 287865 所有,欢迎分享本文,转载请保留出处!

发表评论


表情