Mark Murphy
Mark Murphy

Reputation: 1660

How to prevent OSX popup for incoming connections for Python app?

I am developing a simple python3 server app. I invoke it like this:

python3 bbserver.py

Each time after doing this I get the OSX popup:

Do you want the application “Python.app” to accept incoming network connections?

I've tried making an exception for python3 executable (there is no python3.app) in the firewall and have tried code signing with a codesign certificate thus:

codesign -f -s mycodecert /Library/Frameworks/Python.framework/Versions/3.4/bin/python3 --deep

No luck.

Upvotes: 10

Views: 2909

Answers (2)

I'll Eat My Hat
I'll Eat My Hat

Reputation: 1344

For Anaconda users who have updated to Mojave, you may be running an outdated/unsigned version of Python.

Simply run conda upgrade conda to update Python to the latest version, which should also be signed, and the problem should go away. If it doesn't, then you may need to contact Anaconda's support to get them to build a signed package.

Of course, you will also have to conda upgrade python for each conda environment you have.

Upvotes: 0

Luke Exton
Luke Exton

Reputation: 3676

If you are using a virtualenv or anything similar you could be signing the wrong version of python.

sudo codesign --force --deep --sign - $(which python)

To check the status of the certificate that was used to sign an app:

codesign -dv /Library/Frameworks/Python.framework/Versions/3.4/bin/python3
codesign -dv $(which python)

Example Unsigned:

hostname ~ $ codesign -dv $(which python)
/usr/local/bin/python: code object is not signed at all

Example Signed:

hostname ~ $ workon py27
(py27)hostname ~/py27 $ codesign -dv $(which python)
Executable=/Users/me/.virtualenvs/py27/bin/python
Identifier=python-555549446408a33553ca3f479122ce9278a9a269
Format=Mach-O universal (i386 x86_64)
CodeDirectory v=20100 size=196 flags=0x2(adhoc) hashes=3+2 location=embedded
Signature=adhoc
Info.plist=not bound
TeamIdentifier=not set
Sealed Resources=none
Internal requirements count=1 size=136

Upvotes: 5

Related Questions