Pynotify notify not recognizing "init" module in python

1.3k Views Asked by At

I downloaded the "pynotify" package using pip. After running the code the error is "module 'pynotify' has no attribute 'init'" Thank You for the help.

2

There are 2 best solutions below

0
On

Because there are multiple projects called "pynotify", there's ambiguity. The one that gets installed when doing pip install pynotify is probably not the one you were hoping for.

ubuntu:~/> pip show pynotify
-->cut<--
Name: pynotify
Version: 0.1.1
Summary: Python decorator that notify via email (Gmail) the termination (and eventual stacktrace in case of failure) of a function
-->cut<--

Here's another one that seems to do what you want : And I quickly tested it, it seems to work (shows a notification toaster popup in the screen corner) https://ms7m.github.io/notify-py/

ubuntu:~/> pip install notify-py

ubuntu:~/> python3
>>> from notifypy import Notify
>>> notification = Notify()
>>> notification.title = "Cool Title"
>>> notification.message = "Even cooler message."
>>> notification.send()
True
>>> 
0
On

I don't know but it looks like to be a library conflict.

I already had the same problem and I was not able to solve it. I suggest you to try using subprocess that worked for me, see below:

import subprocess
subprocess.Popen(['notify-send', "Message"])

Note: notify-send command is only Linux distributions.

You can get more notify-send informations here.