Before I took these steps, I ran brew uninstall python
in an attempt to clear out a different Python installation. I also had to clear out some stuff in my .bash_profile
.
- Install Pyenv via Homebrew:
brew update && brew install pyenv
- Add necessary stuff to ~/.bash_profile:
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile
- Restart terminal.
- Maybe install dependencies? (Thouhg you may be good to go already.)
pyenv install --list
and pick new-ish-but-stable versions of python2 and python3 to install. For example:pyenv install 3.7.0 2.7.15
- You can set version 3 as the global, with 2 as fall-back:
pyenv global 3.7.0 2.7.15
. You can also set yoursystem
's Python as a secondary fallback by runningpyenv global 3.7.0 2.7.15 system
.