Python
Python is a popular general-purpose programming language that is especially suited to web development.
Install Python
sh
sudo apt update -y
sudo apt -y install python3
sudo apt -y install python3-venvsh
brew install python@3.14
brew link python@3.14 --force --overwriteCheck Python version
sh
python --versionIn some cases, old Python version can take priority on new version:
sh
Python 3.9.6output
Here a solution for macOS with Homebrew:
sh
export PATH="/opt/homebrew/opt/python@3.14/bin:$PATH"~/.zshrc
Reload your PATH:
sh
source ~/.zshrc
python --versionNow Python v3.14 by Homebrew will be used. If not works, check where is your Python version:
sh
which python3
# OR
which pythonCreate a virtual environment
sh
# Create a virtual environment in your home directory
python3 -m venv ~/venv_python
# Activate the virtual environment
source ~/venv_python/bin/activateAdd the following to your .zshrc:
sh
# export PATH="/opt/homebrew/opt/python@3.14/bin:$PATH" # in some cases for macOS
alias python="python3"
alias py-env="source ~/venv_python/bin/activate"
alias py="source ~/venv_python/bin/activate && python3"Source the .zshrc:
sh
source ~/.zshrcAnd now you can activate the virtual environment by running:
sh
py-envOr run Python directly:
sh
pyUpgrade pip
sh
pip install --upgrade pipUse scripts
Create a script file, like hello.py:
py
print("Hello, World!")hello.py
Run the script:
sh
py hello.pyInstall Python packages
Assure you are in the virtual environment:
sh
py-envInstall packages using pip:
sh
pip install <package>VSCode environment
For VSCode users, use Shift+Ctrl+P / Shift+Cmd+P and select Python: Select Interpreter to select local virtual environment, like /Users/$USER/venv_python/bin/python.