Installation

Environment inspection

List globally installed packages.

pip list
 
pip freeze

To visualise the package dependencies, use pipdeptree.

# Install pipdeptree
pip install pipdeptree
 
# Visualise the dependency tree
pipdeptree

Setting up .venv

It is recommended that a virtual environment be created for your project.

# Use any virtual environment
 
PROJECT_NAME=colab-notebooks
 
python3 -m venv ~/Workspace/${PROJECT_NAME}/.venv
source ~/Workspace/${PROJECT_NAME}/.venv/bin/activate

Load environment variables via python-dotenv

dotenv.load_dotenv()

Install packages listed in the requirements.txt

pip install -r /path/to/requirements.txt

Creating requirements.txt

Create a requirements.txt fire from within an existing project:

pip freeze > requirements.txt

IDE setup for Python.

Install Python LSP server (Emacs)

This is required for the lsp-mode in Emacs.

pip install "python-lsp-server[all]"

Run Jupyter Notebooks with VS Code

  1. Install Jupyter extension for VS Code.

  2. Create a virtual environment in the project directory.

# Use any virtual environment
 
python3 -m venv ~/Workspace/project_name/.venv
source ~/Workspace/project_name/.venv/bin/activate
  1. In VS Code, press Cmd+Shift+P, select Python: Select Interpreter and choose the virtual env you just created.