Install Python 3 to /usr/bin/ on macOS

前端 未结 3 578
梦如初夏
梦如初夏 2021-02-15 17:36

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

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


        
3条回答
  •  醉话见心
    2021-02-15 18:02

    Create a symbolic link in /usr/bin/

    Open terminal and do:

    $ sudo ln /Library/Frameworks/Python.framework/Versions/2.7/bin/python /usr/bin/python
    $ sudo ln /Library/Frameworks/Python.framework/Versions/3.5/bin/python3 /usr/bin/python3
    

    You can now do what you wanted to do.

    Edit: Unfortunately as you can read from the other answers, this solution no longer works on MacOS >= El Capitan due to System Integrity Protection. (See here)

    A possible alternative is to use the folder /usr/local/bin that should be accessible.

提交回复
热议问题