我是靠谱客的博主 调皮黑米,这篇文章主要介绍Mac中升级Python2.7到Python3.5步骤,现在分享给大家,希望可以做个参考。

下载Python3.5 for Mac 一步步安装

安装的默认路径是:/Library/Frameworks/Python.framework/Versions/3.5/


强烈建议 不要直接sudo ln -s (会直接覆盖系统原来的link导致想调用自带python的软件出现问题),修改path variable虽然比较安全,但对于你的需要是没有太大必要的。
想要实现你的如下要求
在终端里直接输入“python”命令就会运行3.5的py版本?
直接在.profile加一个alias就可以了。如果你的Terminal运行的shell是bash(默认),可以修改~/.bash_profile,添加下行(具体的path取决于你的python3安装路径):
alias python="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5"
然后重启一下Terminal或者直接
source ~/.bash_profile

下面的是我的Mac用户的家目录中的.bash_profile内容,供参考

alias ls='ls -G' -->ls 带有颜色的文件显示

alias ll='ls -l'

#unalias ls 

#unalias ll

#export CLICOLOR=1

export LSCOLORS=exfxaxdxcxegedabagacad --->设置的显示的目录和文件的带颜色的

export PATH=$PATH:/usr/local/mysql/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin

export PATH

# Setting PATH for Python 3.5

# The original version is saved in .bash_profile.pysave

export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/3.5/bin:

alias python="/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5"

~                            

如果想要Python2.7的就把.bash_profile中的最后一行注释掉,要用Python3.5.2的就把.bash_proflle的最后一行生效就好,简单方便,我喜欢。



最后

以上就是调皮黑米最近收集整理的关于Mac中升级Python2.7到Python3.5步骤的全部内容,更多相关Mac中升级Python2内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(50)

评论列表共有 0 条评论

立即
投稿
返回
顶部