注意:不要删除2.7的文件夹,mac需要用的
1、将python3.7安装到/System/Library/Frameworks/Python.framework/Versions/目录下:
sudo mv /Library/Frameworks/Python.framework/Versions/3.7 /System/Library/Frameworks/Python.framework/Versions
2、设置Group为wheel,原来系统自带的就是这样的
sudo chown -R root:wheel /System/Library/Frameworks/Python.framework/Versions/3.7
3、在Versions的目录里有一个Current的link,是指向当前的Python版本
sudo rm /System/Library/Frameworks/Python.framework/Versions/Currentsudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7 /System/Library/Frameworks/Python.framework/Versions/Current
4、重新链接可执行文件
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/pydocsudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 /usr/bin/pythonsudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7/bin/pythonw3.7 /usr/bin/pythonwsudo ln -s /System/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config /usr/bin/python-config
5、更新.bash_profile文件
vim ~/.bash_profile (只要能编辑就行)�6�5插入新的Python路径 # Setting PATH for Python 3.6# The orginal version is saved in .bash_profile.pysave PATH="/System/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}" export PATH
然后问题来了,pip安装ssl报错,
pip is configured with locations that require TLS/SSL, however the ssl module in Python is not avail
解决方法:
在~/.pip/pip.conf文件中添加或修改
[global] index-url = http://mirrors.aliyun.com/pypi/simple/ #可以手工指定是http的或者https的 [install] trusted-host=mirrors.aliyun.com
参考:https://blog.csdn.net/mergerly/article/details/80395651
同时参考了以下连接,下面连接文章内容删除2.7有问题,我就是按下面的文章操作,后面xcode出现了错误。
https://blog.csdn.net/xummgg/article/details/69053334