Essential Tools
The UV package (Link)
UV is a Python package management system that replaces pip, pip-tools, pipx, poetry, pyenv, twine, virtualenv, and more, and is said to be 10-100x faster than pip.
You can use homebrew to install uv:
brew install uvAlternatively, install from the official channel:
# On macOS and Linux.
curl -LsSf https://astral.sh/uv/install.sh | shWhen installed via the standalone installer, uv can update itself to the latest version:
uv self updateUsage
# Insatall a specific version of Python
uv python install 3.12
# Create a new Python project
uv init
# Add a dependency to the project
uv add python-dotenv
# Remove a dependency from the project
uv remove python-dotenv
# Sync the project's dependencies with the environment
uv syncuv supports virtual environments, e.g., to create a virtual environment at .venv:
uv venv
# Activate with: source .venv/bin/activate
source .venv/bin/activate
# Deactivate
deactivateEnvironment inspection
List globally installed packages.
pip list
pip freezeTo visualise the package dependencies, use pipdeptree.
# Install pipdeptree
pip install pipdeptree
# Visualise the dependency tree
pipdeptreeSetting 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/activateLoad environment variables via python-dotenv
dotenv.load_dotenv()Install packages listed in the requirements.txt
pip install -r /path/to/requirements.txtCreating requirements.txt
Create a requirements.txt fire from within an existing project:
pip freeze > requirements.txtIDE 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
-
Install
Jupyterextension for VS Code. -
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- In VS Code, press
Cmd+Shift+P, selectPython: Select Interpreterand choose the virtual env you just created.