-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AttributeError: 'NoneType' object has no attribute 'setDelegate_' #9
Comments
Solved the issues. There was something weird with using virtualenvs for some reason and it works great without them. Not sure I understand why, but I'll take it! |
I have the same problem. And I like my virtualenv, it's so cozy! |
Also unable to run the example inside a virtualenv. Same error as above. |
Really a pyobjc issue but reopening as there may be a workaround.
|
+1 |
1 similar comment
+1 |
+1 Encountered this after #12 and #21 (venv2)➜ pyapp python app.py
Traceback (most recent call last):
File "app.py", line 17, in <module>
AwesomeStatusBarApp("Awesome App").run()
File "/Users/ryan/Desktop/pyapp/venv2/lib/python2.7/site-packages/rumps/rumps.py", line 1059, in run
NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self._nsapp)
AttributeError: 'NoneType' object has no attribute 'setDelegate_' |
+1 |
3 similar comments
+1 |
+1 |
+1 |
FWIW, if I check out rumps manually and run some code from within the git checkout (read: if I don't use the |
+1 |
1 similar comment
+1 |
+1 on this... would love to get it working. Is there a pyobjc bug filed? @jaredks Where does the fix you mentioned go? Thanks for making this project. :) |
+1 |
The critical code snippet is
which appears to return None if you have the wrong application bundle properties / plist file. The main python and virtualenv python are somehow different, even if you create your virtualenv with
If I manually copy /usr/bin/python into my virtualenv, then this code snippet starts working (i.e., returns something other than None):
I can also get this working by putting an Info.plist file directly into the same bin dir as my virtualenv's python:
I have automated dynamic generation of this plist in a pull request: |
NSUserNotificationCenter.defaultNotificationCenter() returns None if there is no CFBundleIdentifier in python's plist (MacOS app configuration) file. The default system python has an associated plist; but pythons run in a virtualenv do not. This fix force-sets the CFBundleIdentifier field to be the application name if it is not already set in the plist.
@zollman confirming your fix works for me. I'm using the Anaconda (scientific) python from Continuum. Oddly |
Note for those browsing this: I closed my pull request -- while it prevents the specific error from being thrown, a dynamically-generated Plist won't actually give you the ability to throw real notifications on OS X. Works for the other use cases though. |
+1 |
5 similar comments
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
+1 |
1 similar comment
+1 |
Fix published to PyPI |
\o/ |
thank you @jaredks! Really looking forward to playing with this software now! |
When trying to run any of the examples, I'm running into this error:
Traceback (most recent call last):
File "queue_client.py", line 57, in
app.run()
File "/Users/danielschales/Envs/queue_client/lib/python2.7/site-packages/rumps/rumps.py", line 703, in run
NSUserNotificationCenter.defaultUserNotificationCenter().setDelegate_(self.nsapp)
AttributeError: 'NoneType' object has no attribute 'setDelegate'
This is on a fresh install of Mavericks 10.9.1, using Homebrew installed Python 2.7.6, and installed PyObjC using pip all in a virtualenv. Using tito's fork as well as the official rumps repo. It was working in my previous Mavericks installation, but the system Python install was a mess, hence the reinstall and usage of a virtualenv this time around.
The text was updated successfully, but these errors were encountered: