ntfy icon indicating copy to clipboard operation
ntfy copied to clipboard

[tip] Problem with linux notifications - solved

Open MattPorto opened this issue 9 years ago • 8 comments
trafficstars

Hi guys, Trying to run a $ntfy send test command after installing ntfy using sudo pip install ntfy and i get the following exception:

ERROR: Failed to send notification using default
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/ntfy/__init__.py", line 48, in notify
    **backend_config)
  File "/usr/local/lib/python2.7/site-packages/ntfy/backends/default.py", line 22, in notify
    raise DefaultNotifierError(e, module)

DefaultNotifierError

I searched something like this in the closed issues and i found the issue #95, where the SteveEdson had the same problem and he said that he ran the command $ cat ~/.config/ntfy/ntfy.yml to check if the config file is ok, and there i noticed that this path doesn't exist on my .config folder. So I created the ntfy folder using mkdir ntfy and then i used a text editor to create the ntfy.yml and put the following code inside it:

--- 
backends: 
    - linux

so, when i ran $ ntfy send test again, it resulted in the follow message:

ImportError: No module named dbus

So i realized that i don't had the dbus package installed on my machine, then i ran sudo apt-get install python-dbus to install this and when i ran again $ntfy send test it works pretty nice!

Maybe it is too obvious or a newbie question, but i decide to post it here because it stucked me when i try to run the script for the first time, and i wasted some time to discover how to fix that. I hope that issue can help someone that have the same trouble when try to install the app, so i think that can be usefull.

se ya! :)

MattPorto avatar Sep 04 '16 16:09 MattPorto

Thanks, I managed the first part :) But with pip (installed with Anaconda), I didn't manage to install the dbus dependency and gave up... If someone manage to do this, please let me know.

DanielAndreasen avatar Sep 06 '16 14:09 DanielAndreasen

I'll look into adding python-dbus to the deps on linux. It was just always present (in the system site-packages) on distros I used.

dschep avatar Sep 06 '16 14:09 dschep

After downloading the python-dbus it fixed the "ntfy test" problems on my end. Thank you @MattPorto for this tip. Really appreciate it and I recommend adding this to the Quick Start guide for newbies like me.

EDIT. The problem I'm having is that after running the other tests it seems that I'm getting new errors and ntfy send test has stopped working

Hirmuli avatar Nov 11 '16 07:11 Hirmuli

What're your new errors @Hirmuli?

dschep avatar Nov 11 '16 15:11 dschep

@dschep

ntfy send test _ERROR: Failed to send notification using default Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/ntfy/init.py", line 65 in notify **backend_config) File "/usr/local/lib/python2.7/dist-packages/ntfy/backends/dafault.py", line 22, in notify raise DefaultNotifierError(e,module) DefaultNotifierError

ntfy test worked until I started to try out the "Quick start guide"

Even the test stopped working after I ran ntfy -e "backends", also pushover didnt work or the other notifications. Only ntfy test and ntfy custom title worked.

Hirmuli avatar Nov 14 '16 11:11 Hirmuli

I had a similar problem in Ubuntu 16.04. What solved the issue for me was installing the following dbus dev packages:

sudo apt install libdbus-1-dev libdbus-glib-1-dev

and then installing the python dbus module:

sudo pip install dbus-python

mccarthyryanc avatar Jan 05 '17 17:01 mccarthyryanc

I get the same error as @Hirmuli when i am trying to call p = Popen("ntfy -b pushbullet -o access_token token send 'test'", shell=True) from a python program. I tried what @mccarthyryanc suggested but no luck. Do you have any other suggestions?

DinosL avatar Jun 23 '17 20:06 DinosL

@DinosL did you follow @mccarthyryanc's directions regarding dbus-python and install globally or if in a virtualenv, ensure that --system-site-packages was set when creating it?

Once that works, you also have the option in python since ntfy is written in python of just doing:

from ntfy import notify
notify("Message body", "mesage title") # note a title is required, where as the CLI will set a default title

dschep avatar Jun 26 '17 12:06 dschep