Shit, shit and shit! I hate to have to remember those commands when setting up my python environment on my MacOS and configuring it to 3.8.5.
So here you go, a cheatsheet to nail it forever!
Install pyenv
brew install pyenv
Set the path correctly
$ echo ‘PATH=$(pyenv root)/shims:$PATH’ >> ~/.zshrc
List locally installed versions
$ pyenv versions
system
List all available python versions from all repositories
pyenv install --list
Install specific version
pyenv install 3.8.5
Again, List locally installed versions
$ pyenv versions
* system (Set by /Users/you/.pyenv/version)
3.8.5
Set python version as global version
pyenv global 3.8.5
Create venv environment
python -m venv venv
Activate venv environment
source ./venv/bin/activate
Update pip
pip install --upgrade pip# orpython -m pip install --upgrade pip
Use a different local version of python for a specific project
mkdir my_project
pyenv local 3.4.5
cat .python-version # Just to check
python -m venv venv
source ./venv/bin/activate
Hope this nails it forever.
Reference: https://opensource.com/article/20/4/pyenv