How to allow Python.app to firewall on Mac OS X?

老子叫甜甜 提交于 2019-11-30 13:56:32

Apparently El Capitan has something call System Integrity Protection that prevents any user (even root) to modify certain OS resources. Such as the /usr/bin directory in this case, where you have the python executable. To self sign the python binary you can disable SIP by rebooting your mac in recovery mode (reboot while holding CMD+R) and then typing this in the terminal:

csrutil disable

then boot back into regular OSX, and follow the steps to self sign python and execute:

codesign -s "My Signing Identity" -f $(which python)

and finally reboot back into Recovery Mode, and re-enable SIP:

csrutil enable

I installed Python 3.6 from python.org, and I had a similar problem. I tried repeatedly to self-sign the python binaries /usr/local/bin/python3, /Library/Frameworks/Python.framework/Versions/3.6/bin/python3, and so forth, but I would keep getting the MacOS Firewall Deny/Allow popup.

Finally, self-signing the application located at /Library/Frameworks/Python.framework/Versions/3.6/Resources did the trick:

codesign --force --sign "My Signing Identity" /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app

I'm on MacOS Mojave 10.14.1 for what that's worth.

Slight addendum to the answer by @mr-howdy above. For Python 3.7, I had to use:

codesign --force --sign "My Certificate" /Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python

Note the extra Contents/MacOS/Python added to the path.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!