简体   繁体   中英

Unable to upgrade python 3.8 from 3.7.7 in macOS

I am getting error when I try

brew install python3

python 3.7.7 已经安装

I think the warning said it all. brew link python3 will give you python 3.7.7 .

If you like to use python 3.8 , you can use brew install python@3.8 instead.

The best approach to manage Python versions is to follow Moshe Zadka's recommendations:

  1. Install Python environment manager pyenv :
$ brew install pyenv
  1. Install version version as you require using pyenv install python-version, eg:
$ pyenv install 3.8.3
  1. Set your global default version: using pyenv global python-version, eg:
$ pyenv global 3.8.3
  1. Add this version to your configuration file ( .zshrc or .bash_profile which ever you use) to work correctly, eg:
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.zshrc

Your configuration file will then be updated with the following:

if command -v pyenv 1>/dev/null 2>&1; then
  eval "$(pyenv init -)"
fi

Then you're good to go.

-enjoy Python!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM