0

I just built a python mac app using rumps and py2app. Everything works flawlessly when I generate a .app. I decided to implement a button to download an update when it's available, for this I use the requests package (I also have an implementation with urllib) to look up if a new update is available (simple get request to the github api).

When I run the script with python in my shell, the rumps app works perfectly with the update system. But when I generate the py2app app, the app crashes. This is the traceback in the console :

Traceback (most recent call last):
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/__boot__.py", line 351, in <module>
    _run()
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/__boot__.py", line 336, in _run
    exec(compile(source, path, 'exec'), globals(), globals())
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/main.py", line 26, in <module>
    class StatusBarApp(rumps.App):
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/main.py", line 92, in StatusBarApp
    update = is_update_available()
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/main.py", line 85, in is_update_available
    auth=('med', '2d6ff03b3a7cf266be953429e5efdcc121fd9b96'))
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/lib/python2.7/requests/api.py", line 67, in get
    return request('get', url, params=params, **kwargs)
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/lib/python2.7/requests/api.py", line 53, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/lib/python2.7/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/lib/python2.7/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/Users/me/Desktop/myrumpsapp/dist/MyApp.app/Contents/Resources/lib/python2.7/requests/adapters.py", line 447, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: Can't connect to HTTPS URL because the SSL module is not available.
MyApp Error

It seems like there is a problem with SSL, I believe that py2app is unable to link something like libssl that is necessary for requests (similar issue with urllib).

I am on Mac OSX ElCapitan, I use a conda env (like virtualenv for the anaconda python scientific distribution) with Python 2.7.11 .

Does somebody know how to tackle this problem ?

PS: My setup.py

from setuptools import setup

APP = ['main.py']
DATA_FILES = []
OPTIONS = {
    'argv_emulation': True,
    'plist': {
        'LSUIElement': True,
    },
    'packages': ['rumps', 'requests'],
}

setup(
    app=APP,
    name='MyAPP',
    data_files=DATA_FILES,
    options={'py2app': OPTIONS},
    setup_requires=['py2app'],
)
mandok
  • 492
  • 1
  • 5
  • 20
  • Does anyone has any idea ? – mandok Dec 20 '15 at 12:32
  • I suspect it has to do with the way you built Python and ***`Modules/Setup.dist`***. Also see [Installing python with ssl support in ~/local](http://stackoverflow.com/a/5939170/608639). – jww Dec 20 '15 at 21:49
  • Hey, thanks for your help. I'm using anaconda so I don't think it's possible to do this, anaconda comes with it's own ssl folder – mandok Dec 21 '15 at 16:34
  • @mandok did you solve this problem?.I am only using the `requests` module, so I think it only has to do it. I haven't found a solution yet. – muammar Jun 21 '16 at 23:04
  • @muammar hi, unfortunately I was not able to solve this issue and i'm still looking for a solution. I tried using urllib and I encountered the same issue. – mandok Jun 27 '16 at 08:43
  • @mandok take a look at this -> https://github.com/muammar/mkchromecast/commit/08667049492daaf16f72a9a3a742fffb4aae47d5 I solved it doing that. – muammar Oct 29 '16 at 23:53

0 Answers0