With the OS X firewall enabled, you can remove the "Do you want the application “Python.app” to accept incoming network connections?" message.
You can simply select "Allow All" in your firewall, or simply turn it off.
Settings —> Security & Privacy —> Firewall —> Off
Create a self-signed certificate.
- Open Keychain Access. Applications > Utilities > Keychain Access.
- Keychain Access menu > Certificate Assistant > Create a Certificate...
- Enter a Name like "Python-App-Cert".
- Select Identity Type: Self Signed Root
- Select Certificate Type: Code Signing
- Check the Let me override defaults box
- Click Continue，Enter a unique Serial Number，such as 1
- Enter 7300 for Validity Period. (gives you 20 years 365*20)
- Click Continue for the rest of the dialogs
- Email, Name, etc. fill out as you wish. email@example.com; Python-App-Cert; mimvp.com; ceo; beijing; beijing; CN
- Key pair info: set to RSA, 2048 bits. Does not really matter IMHO.
- From "Key Usage Extension" up to "Subject Alternate Name Extension": accept the defaults.
- Location: login keychain.
- Once it is created, set to "Always trust" in the Login keychain: right-click on the certificate, choose "Get Info",
- in the "Trust" section, set "When using this certificate" to "Always trust".
Now sign your application
sudo codesign -s <certname> -f --deep /path/to/
sudo codesign -s "Python-App-Cert" -f /Library/Frameworks/Python.framework/Versions/2.7/bin/python
sudo codesign --force --deep --sign - /Library/Frameworks/Python.framework/Versions/2.7/bin/python
If that doesn't help, try without
--deep and without the trailing slash:
sudo codesign --force --sign - /Library/Frameworks/Python.framework/Versions/2.7/bin/python
Note that when using a virtual environment,
you need to activate the virtual environment before running this command.
In the dialog that appears, click "Allow".