ntfy
ntfy copied to clipboard
AttributeError: 'NoneType' object has no attribute 'scheduleNotification_' on macOS Sierra (10.12.6)
update
If I use the system python, it seems to work. Therefore, I added a simple wrapper:
ntpy () {
pyenv shell system
ntfy "$@"
pyenv shell --unset
}
This fixes triggering a notification, for now. But haven't even tried messing around with all the other fancy stuff ntfy
does.
Mac support is not a huge priority for me as I'm migrating off it (hopefully) anyhow.
debugging
I'm guessing this might have something to do with permissions or something...
Running:
- ntfy 2.5.1
- iTerm
Build 3.1.5.beta.2
- GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin15.6.0)
- python 3.6.1
- pyenv 1.1.0
Did the install quickly with sudo pip install ntfy
(later tried omitting the sudo) and did ntfy send test
:
(also tried above command with sudo)
Seems like NSUserNotificationCenter.defaultUserNotificationCenter()
(docs at https://developer.apple.com/documentation/foundation/nsusernotificationcenter) is not returning anything
Got curious and started printing out stuff using https://pythonhosted.org/pyobjc/api/module-objc.html - no protocols on NSUserNotificationCenter
and the properties are shown below - don't really know anything about Objective C
Notifications center settings don't look too interesting:
Looks like the Console.app log says this:
Nothing in the system.log..
I also set up a very minimal ~/.ntfy.yml
:
Also tried adding
darwin:
prio: DEBUG
Not sure that's right - but I seem to see more logs? This taskgated thing seems to do with SIP, or System Integrity Protection and it seems to be not so easy to disable (https://apple.stackexchange.com/questions/281006/how-to-stop-taskgated-on-sierra)
Holy crap, that's the most detailed issue I've ever gotten. nice!
I imagine it's an issue with pyenv & pyobjc as you've got it working with the system python. To avoid the setting/unsetting of the python, I'd suggest editing the shebang line that setuptools created. using:
nano $(which ntfy)
Change the first line starting with #!
to #!/the/absolute/path/to/your/system/python
(probably somewhere in in /Library/Frameworks
, but not sure since I don't use a mac)and the ntfy should always use the system python without needing to change your shell's python.
UPDATE: answered while drafting this - easy_install .
inside the repo using a homebrew easy_install
(in my case).
I didn't end up pursuing this much but came back to it tonight (still on a mac, sadly). Bottom line upfront - ~~how can I build the script from source on a mac?~~ 😄
I'd like to get that shell integration working but when I tried to change up the hashbang it couldn't find ntfy.cli
- I pip installed it with pyenv running under pip.
Sadly, I also apparently have python from homebrew - seems they are dependencies of something else (since they don't show up as leaves when running brew leaves | grep python
). I also have python installed via https://github.com/NixOS/nixpkgs 🤷♂️ - it's a hopefully temporary situation...
Mac has its system python under /usr/bin/python
and it also has /usr/bin/easy_install
built in.
I cloned down the repo and ran /usr/bin/python setup.py --help-commands
to explore some commands, but I don't really know what I'm doing...
Eventually I moved on from that and tried easy_install .
- accidentally using the homebrew version rather than the system one, and apparently it worked (?) and installed it under /usr/local/bin/easy_install
. Afterwards I tried to use the system one and that didn't work.
So far, shell integration seems to be working.
What if you remove ntfy. Then install it explicitly with the system python?
pyenv shell system
python -m pip install ntfy
(not sure if you'll still have to make shebang line tweaks then for it to still work when non-system python is activated)
Hi, for me it solved this way:
- uninstall the ntfy that was not working (
pip uninstall ntfy
) - get all my python binaries , and use the one I've installed via homebrew (
where python
>/usr/local/bin/python
) - install as @dschep suggested, but using my brew's python (
/usr/local/bin/python -m pip install ntfy
)
Thanks for sharing!