Use pyenv and a .python-version file

Problem: Have you ever downloaded someones project and ran into python versioning issues?

Solution: You need to pin the python version for every project

How?

pyenv will recognize a .python-version file and use the python version that you pinned for your project, directory or system.

This is massively useful when working across different machines and engineers.

Installing a new python version is as easy as

$ pyenv install 3.9.11

Setting this as your directory python version

$ echo "3.9.11" > .python-version

Thats it! You can add this to your git history and everyone can work off the same python version.

Note: Make sure you set up your shell to use pyenv. Here is the code for zsh

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

https://github.com/pyenv/pyenv#set-up-your-shell-environment-for-pyenv

More info