如何在RPi3上安装和使用pythonpygobject“Notify”(或等效的)

2024-03-28 11:21:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图从一个github repo安装一个基于Python的包,它最初是为另一个(可能是基于Debian的)Linux发行版安装的。在

程序似乎使用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)

但是,当我试着运行程序时,我得到的是:

^{pr2}$

我在google上搜索过自己累了,唯一发现的是一些关于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.
  • 运行pip2 search notify会返回数百个看似不相关的内容。在
  • apt search notify相同。在

问:如何找到并安装正确的Notify东西?


Tags: thefromimport程序queueaslibrarynotify
1条回答
网友
1楼 · 发布于 2024-03-28 11:21:15

在发布问题后不久,我就找到了解决方案。在

$ 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.

然后通过安装以下部件来解决问题:

^{pr2}$

但也可以将notify2与:sudo pip2 install notify2一起使用。在

相关问题 更多 >