If you recently installed python and its not setting latest path you may need to use following method to install python correctly in unix systems. Most of the users intend to create symlinks replacing python 2 with python 3 and its not a proper way to switch the versions. For that you can use
pyenv and change desired python version easily.
pyenv using brew.
Use homebrew to install pyenv in your os.
brew install pyenv
2. Install desired python version
You can check python versions from here https://www.python.org/downloads/. Once you have determined your version you can install it by using
pyenv install 3.9.9
After installing the python version you nee to select the version as the global
pyenv global 3.9.9 pyenv version >> 3.9.9 (set by /Users/user/.pyenv/version) python -V >> Python 3.9.9
3. Add variables to your shell
First determine your shell executing following command in the terminal
ps -p $$
Then enter following variables and commands in the relevant config file. Since my shell is
zsh I will be editing
~/.zshrc. If its bash you can edit
export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" export PIPENV_PYTHON="$PYENV_ROOT/shims/python" plugin=( pyenv ) eval "$(pyenv init --path)" eval "$(pyenv init -)"
Finally source your config file.
source ~/.zshrc // or source ~/.bash_profiles
Thats it. Next time when you open the terminal the values will be read from the config file and working by default