Skip to content

Instantly share code, notes, and snippets.



Last active Apr 5, 2021
What would you like to do?

🔥 Python Version Manager (CheatSheet)

Install PyEnv

# 1. Install
brew install pyenv

# 2. export to .zshrc
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 -)"\nfi' >> ~/.zshrc

# 3. Get Python available versions
pyenv install -l

# 4. Install wanted version (ex. 3.9.4)
pyenv install 3.9.4

# 5. Set that version as global python version
pyenv global 3.9.4

# 6. verify that the python version has been changed successfully
python --version

What about pip ?

Well if u got any error with pip after this, just run this :

pip3 install --upgrade --force-reinstall pip

Troubleshoting :

If u got errors with previous python versions or any linking error (ex. directory do not exist) well clean all this folders from python reference.

  • /usr/local/Cellar
  • /Library/Frameworks/Python.framework/
  • /usr/local/opt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment