Mac os python升级

MAC 系统自带python2,升级到python3的操作:

brew install python

brew upgrade python

安装结束后会有下面提示:

If you need to have [email protected] first in your PATH, run:

  echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc

For compilers to find [email protected] you may need to set:

  export LDFLAGS="-L/usr/local/opt/[email protected]/lib"

For pkg-config to find [email protected] you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig"

将这三个环境变量和 alias python='python3'

配置到 ~/.bash_profile

source ~/.bash_profile

同时配置~/.zshrc

if [ -f ~/.bash_profile ]; then

   source ~/.bash_profile

fi

export PATH=/usr/local/opt/[email protected]/bin:$PATH

python --version 验证为结果

你可能感兴趣的:(python)