1. 打开终端
    vim ~/.bash_profile

  2. 写入python的外部环境变量(本人的版本是3.8)
    export PATH=${PATH}:/Library/Frameworks/Python.framework/Versions/3.8/bin

在/usr/local/bin/python3.8路径下可查看具体的python安装路径

  1. 重命名python
    alias python="/Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8"
    (这步很重要,直接关系到默认启动的python版本是否修改)

  2. source ~/.bash_profile

  3. 在终端调用python,查看是否修改成功

lilianhong@lilianhongdeMacBook-Pro ~ % python
Python 3.8.6 (v3.8.6:db455296be, Sep 23 2020, 13:31:39) 
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐