PYTHON_VERSION="3.10.5"
brew install pyenv
pyenv install $PYTHON_VERSION
pyenv global $PYTHON_VERSIONOpen your .zshrc file and add the lines below at the end of the file.
code ~/.zshrcor, use vi
vi ~/.zshrcCopy and paste the following lines:
# Python - pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
You should now close your terminal exit and re-open it.
Check python and pip
which python
which pipList of existing version installed on your mac:
pyenv versionsSet a new version of python on your mac:
pyenv global $PYTHON_VERSIONCreate a new file
code hello.pyEdit your file with visual studio and write this line:
print("Hello World")Run the script hello.py in your terminal
python hello.py