| | | | | linguist.page@gmail.com

Check Python version

Type here
python3 --version

Create a Python virtual environment

Type here
python3 -m venv env

Activate a virtual environment on Linux or Mac

Type here
source env/bin/activate

Deactivate the current virtual environment

Type here
deactivate

Install a Python package

Type here
pip install package-name

Install all packages from a requirements file

Type here
pip install -r requirements.txt

Save current environment packages to a file

Type here
pip freeze > requirements.txt

List installed Python packages

Type here
pip list

Run a Python script

Type here
python3 script.py

Run a Python script and save output to a file

Type here
python3 script.py > output.txt

Run a Python one-liner from the terminal

Type here
python3 -c "print('hello')"