Upgrading Python 3.7 to 3.9 on macOS Big Sur
Question:
I’m trying to upgrade Python 3.7 to 3.9 on macOS Big Sur. I’m also trying to avoid losing packages that were installed on Python 3.7 and reinstalling them again on Python 3.9
I tried using
brew install python3
brew update && brew upgrade python
which yielded
Already up-to-date.
Warning: python3 3.9.1_7 already installed
However when I run python3 --version
it yields Python 3.7.0
Is this an issue with the alias? Is there a way to uninstall Python 3.7 and keep Python 3.9?
Running brew link python3
yields
Linking /usr/local/Cellar/[email protected]/3.9.1_7...
Error: Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
rm '/usr/local/bin/2to3'
To force the link and overwrite all conflicting files:
brew link --overwrite [email protected]
To list all files that would be deleted:
brew link --overwrite --dry-run [email protected]
Answers:
I fixed this frustrating error by first removing the Python 3.7 manually, by deleting it from the Applications
folder and then uninstalling Python 3.9 using brew uninstall python3
Next, I downloaded and installed the latest Python from here and it worked!
To save all the installed packages by generating a requirements file, Run
python3 -m pip freeze > requirements.txt
and to install them in another environment, Run
python3 -m pip install -r requirements.txt
I suggest use official binaries:
- Download version you need from the python.org
- Call the
.pkg
- Invoke
Update Shell Profile.command
script under /Applications/Python 3.XX/
- After all reboot your terminal
- Check your Python version. The old version and dependencies remain intact.
I’m trying to upgrade Python 3.7 to 3.9 on macOS Big Sur. I’m also trying to avoid losing packages that were installed on Python 3.7 and reinstalling them again on Python 3.9
I tried using
brew install python3
brew update && brew upgrade python
which yielded
Already up-to-date.
Warning: python3 3.9.1_7 already installed
However when I run python3 --version
it yields Python 3.7.0
Is this an issue with the alias? Is there a way to uninstall Python 3.7 and keep Python 3.9?
Running brew link python3
yields
Linking /usr/local/Cellar/[email protected]/3.9.1_7...
Error: Could not symlink bin/2to3
Target /usr/local/bin/2to3
already exists. You may want to remove it:
rm '/usr/local/bin/2to3'
To force the link and overwrite all conflicting files:
brew link --overwrite [email protected]
To list all files that would be deleted:
brew link --overwrite --dry-run [email protected]
I fixed this frustrating error by first removing the Python 3.7 manually, by deleting it from the Applications
folder and then uninstalling Python 3.9 using brew uninstall python3
Next, I downloaded and installed the latest Python from here and it worked!
To save all the installed packages by generating a requirements file, Run
python3 -m pip freeze > requirements.txt
and to install them in another environment, Run
python3 -m pip install -r requirements.txt
I suggest use official binaries:
- Download version you need from the python.org
- Call the
.pkg
- Invoke
Update Shell Profile.command
script under/Applications/Python 3.XX/
- After all reboot your terminal
- Check your Python version. The old version and dependencies remain intact.