Skip to content

Latest commit

 

History

History
78 lines (56 loc) · 1.13 KB

File metadata and controls

78 lines (56 loc) · 1.13 KB

Learning Python

Prepare pyenv

PYTHON_VERSION="3.10.5"

brew install pyenv
pyenv install $PYTHON_VERSION
pyenv global $PYTHON_VERSION

Open your .zshrc file and add the lines below at the end of the file.

code ~/.zshrc

or, use vi

vi ~/.zshrc

Copy 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 pip

Some Utilities of pyenv

List of existing version installed on your mac:

pyenv versions

Set a new version of python on your mac:

pyenv global $PYTHON_VERSION

Your First Python Program

Create a new file

code hello.py

Edit your file with visual studio and write this line:

print("Hello World")

Run the script hello.py in your terminal

python hello.py

Running

Screenshot