not*_*bit 0 python pip notify pygobject raspberry-pi3
我正在尝试从最初用于另一个(可能是基于 Debian 的)Linux 发行版的 github 存储库安装基于 Python 的软件包。
程序好像用的是Python2,导入如下:
import argparse
import logging
import Queue
import collections
import ConfigParser
import os
import socket
import random
import gi
gi.require_version('Notify', '0.7')
from gi.repository import Notify
from multiprocessing import Process, Queue as MPQueue, Event
...
def notif(msg):
Notify.init("TheProg")
notice = Notify.Notification.new("Critical !", msg)
notice.set_urgency(2)
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试运行该程序时,我得到了这个:
$ python2 main.py -h
Traceback (most recent call last):
File "main.py", line 11, in <module>
gi.require_version('Notify', '0.7')
File "/usr/lib/python2.7/dist-packages/gi/__init__.py", line 100, in require_version
raise ValueError('Namespace %s not available' % namespace)
ValueError: Namespace Notify not available
Run Code Online (Sandbox Code Playgroud)
我已经厌倦了谷歌搜索,唯一发现的是对PyGObject API Reference 的一些神秘引用:
gir1.2-notify-0.7 (0.7.7-3)
Parent Project:
Desktop notification library (libnotify is a library for sending desktop notifications)
Description:
A library that sends desktop notifications to a notification daemon, as
defined in the Desktop Notifications spec. These notifications can be
used to inform the user about an event or display some form of
information without getting in the user’s way.
Run Code Online (Sandbox Code Playgroud)
pip2 search notify
返回数百个看似无关的东西。apt search notify
.问:如何找到并安装正确的Notify
东西?
发布问题后不久,我找到了解决方案。
$ apt show gir1.2-notify-0.7
Package: gir1.2-notify-0.7
Source: libnotify
Version: 0.7.6-2
Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>
Installed-Size: 22.5 kB
Depends: gir1.2-gdkpixbuf-2.0, gir1.2-glib-2.0, libnotify4 (>= 0.7.3)
Priority: optional
Section: introspection
Download-Size: 19.8 kB
APT-Manual-Installed: yes
APT-Sources: http://mirrordirector.raspbian.org/raspbian/ jessie/main armhf Packages
Description: sends desktop notifications to a notification daemon (Introspection files)
A library that sends desktop notifications to a notification daemon, as
defined in the Desktop Notifications spec. These notifications can be
used to inform the user about an event or display some form of
information without getting in the user's way.
.
This package can be used by other packages using the GIRepository format to
generate dynamic bindings.
Run Code Online (Sandbox Code Playgroud)
然后通过安装解决了问题:
$ apt show gir1.2-notify-0.7
Package: gir1.2-notify-0.7
Source: libnotify
Version: 0.7.6-2
Maintainer: Debian GNOME Maintainers <pkg-gnome-maintainers@lists.alioth.debian.org>
Installed-Size: 22.5 kB
Depends: gir1.2-gdkpixbuf-2.0, gir1.2-glib-2.0, libnotify4 (>= 0.7.3)
Priority: optional
Section: introspection
Download-Size: 19.8 kB
APT-Manual-Installed: yes
APT-Sources: http://mirrordirector.raspbian.org/raspbian/ jessie/main armhf Packages
Description: sends desktop notifications to a notification daemon (Introspection files)
A library that sends desktop notifications to a notification daemon, as
defined in the Desktop Notifications spec. These notifications can be
used to inform the user about an event or display some form of
information without getting in the user's way.
.
This package can be used by other packages using the GIRepository format to
generate dynamic bindings.
Run Code Online (Sandbox Code Playgroud)
但您也可以将notify2与:一起使用sudo pip2 install notify2
。