在macOS上将Python 3安装到/usr/bin/ [英] Install Python 3 to /usr/bin/ on macOS

查看:1057
本文介绍了在macOS上将Python 3安装到/usr/bin/的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用自制软件安装了python2.x和python3.x,下面列出了可执行的python路径:

I installed python2.x and python3.x using homebrew and the executable python paths are listed below:

$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

$ which python3
/Library/Frameworks/Python.framework/Versions/3.5/bin/python3


在python代码中编写shebang使其在Terminal上可运行太长了,而且还不够干净:


It's quite too long and not so clean to write a shebang in a python code to make it runnable on Terminal:

#!/Library/Frameworks/Python.framework/Versions/2.7/bin/python OR
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3


我更喜欢

#!/usr/bin/python OR
#!/usr/bin/python3

我的问题是,如何在macOS上将python正确地移动或重新安装到/usr/bin ,例如
/usr/bin/python/usr/bin/python3


/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Library/Frameworks/Python.framework/Versions/3.5/bin/python3

My issue here is, how can I correcly move or reinstall python on macOS to /usr/bin such as
/usr/bin/python OR /usr/bin/python3

Instead of
/Library/Frameworks/Python.framework/Versions/2.7/bin/python /Library/Frameworks/Python.framework/Versions/3.5/bin/python3

推荐答案

在Mac OS X El Capitan上这不再可行,因为从那时起,系统完整性保护阻止了这种情况. 中的更多信息usr/bin甚至是sudo

This is NOT possible on Mac OS X El Capitan anymore as from then on System Integrity Protection prevents that. More info in Cannot create a symlink inside of /usr/bin even as sudo

这篇关于在macOS上将Python 3安装到/usr/bin/的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆