I have already installed pynotify, still getting error no module named pynotify

本小妞迷上赌 提交于 2019-12-13 01:23:47

问题


I have already installed pynotify using :

pip install py-notify

When I re-run this it shows :

Requirement already satisfied (use --upgrade to upgrade).

I also tried :

pip install --upgrade py-notify 

but it shows :

Requirement already up-to-date.

Below is my simple code to show desktop notification using pynotify.

import pynotify    
pynotify.init("Basic")

n = pynotify.Notification("Title", "Some sample content")
n.show()

What should I do now to run below code correctly?


回答1:


If you need to send GTK balloons - you've not installed correct library.

If you want to use "Observer programming pattern" (callback management) - you are using incorrect syntax.

There are two similar packages:

  • pynotify - wrapper for libnotify that shows desktop balloons to notify user about some events. Requires PyGTK (http://www.pygtk.org/) to work. Can't be installed from pip. Usually installed with some OS package (something like python-pynotify). Usage: import pygtk;pygtk.require('2.0');import pynotify.
  • notify2 (https://pypi.python.org/pypi/notify2) - alternative wrapper for libnotify. Can be installed from pip. Usage: import notify2

There are also two unrelated packages with similar names:

  • pyinotify (https://pypi.python.org/pypi/pyinotify) - wrapper for libinotify that allows to monitor filesystem changes. Usage: import pyinotify.
  • py-notify (https://pypi.python.org/pypi/py-notify) - python-only library that implements hooks (callback) storage, calling and filtering with no connections to outside world (third-party libraries or standards). Usage: import notify.



回答2:


faced same problem on Ubuntu 16.04

sudo apt-get install python-notify 

worked for me




回答3:


There's a names conflict with pynotify.

I had installed pynotify from PIP using:

sudo pip install pynotify

Since that was the wrong choice, I removed it with:


sudo pip uninstall pynotify

And then installed the expected pynotify using:

sudo apt install python-notify


来源:https://stackoverflow.com/questions/37085869/i-have-already-installed-pynotify-still-getting-error-no-module-named-pynotify

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!