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 python3Create a virtual environment
sh
# For Ubuntu/Debian systems
sudo apt -y install python3-venvsh
# 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
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.