/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install pyenv
pyenv install 3.9.2
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.bash_profile
source ~/.bash_profile
OR add the Open your ~/.bash_profile then add the commands below at the bottom
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n eval "$(pyenv init --path)"\nfi' >> ~/.zshrc
source ~/.zshrc
Some guides will use eval "$(pyenv init -)" instead of eval "$(pyenv init --path)"
In my case eval "$(pyenv init --path)" worked
System:
- MacOS Majove v10.14.6
- Homebrew 3.2.5
- pyenv 2.0.4
https://github.com/pyenv/pyenv#uninstalling-pyenv
The simplicity of pyenv makes it easy to temporarily disable it, or uninstall from the system.
-
To disable Pyenv managing your Python versions, simply remove the
pyenv initinvocations from your shell startup configuration. This will remove Pyenv shims directory fromPATH, and future invocations likepythonwill execute the system Python version, as it was before Pyenv.pyenvwill still be accessible on the command line, but your Python apps won't be affected by version switching. -
To completely uninstall Pyenv, remove all Pyenv configuration lines from your shell startup configuration, and then remove its root directory. This will delete all Python versions that were installed under the
$(pyenv root)/versions/directory:rm -rf $(pyenv root)If you've installed Pyenv using a package manager, as a final step, perform the Pyenv package removal. For instance, for Homebrew:
brew uninstall pyenv
https://www.freecodecamp.org/news/python-version-on-mac-update/