当前位置:   article > 正文

Mac安装python2和python3,并配置

mac安装python2

1 下载

分别下载python2.X和python3.X

2 添加路径

python2、3到路径添加到bash_profile中(以安装到python2和anaconda3为例,一定要填写正确到python路径)

# Setting PATH for Python 2.X
PATH="/System/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
# Setting PATH for Python 3.X
PATH="/Users/hlj/opt/anaconda3/bin:$PATH"
  • 1
  • 2
  • 3
  • 4
  • 5

3 声明

将python指令声明到具体路径

alias python2='/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'
alias python3='/Users/hlj/opt/anaconda3/bin/python3.8'
alias python=python3
  • 1
  • 2
  • 3

4 刷新

source ~/.bash_profile
source ~/.bashrc 
  • 1
  • 2

完成后,控制台输入python2或python,进入python2.7环境中;输入python3,进入python3.8环境中。

致谢
https://www.cnblogs.com/dylancao/p/10234094.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/501467
推荐阅读
相关标签
  

闽ICP备14008679号