mac版python3.7安装教程_mac下安装配置python3.7

1.安装

方法一:官网下载

进入官网https://www.python.org,下载Mac OS X 64-bit/32-bit installer或者Mac OS X 64-bit installer,根据电脑具体情况自己选择,具体操作如图所示

笔记PAGE1

安装成功后也许会碰到pip命令不可用的问题,解决方法如下:

采用方法二homebrew安装,安装mac神器homebrew之后,打开终端,输入命令brew reinstall python3

方法二: homebrew安装

安装mac神器homebrew,打开终端,输入命令# /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安装python3.7# brew install python3

2.配置

打开终端,输入命令,删除mac自带的Python2.7# sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7

把安装好的Python目录移到原本系统python的目录位置# sudo mv /Library/Frameworks/Python.framework/Versions/3.7 /System/Library/Frameworks/Python.framework/Versions

将文件所属的Group修改为wheel# sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.7

更新一下Current的Link,重新链接一下# sudo rm /System/Library/Frameworks/Python.framework/Versions/Current# sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7 /System/Library/Frameworks/Python.framework/Versions/Current

把系统原来的python执行文件删掉# sudo rm /usr/bin/pydoc# sudo rm /usr/bin/python# sudo rm /usr/bin/pythonw# sudo rm /usr/bin/python-config

重新链接可执行文件,建立链接,配置成功!# sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7/bin/pydoc3.7 /usr/bin/pydoc# sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 /usr/bin/python# sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7/bin/pythonw3.7 /usr/bin/pythonw# sudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config /usr/bin/python-config

注意

方法一安装有时候会出现一些问题,比如pip命令无法使用等问题,方法二安装python出现问题的几率比较小,故本人推荐方法二安装python比较简单