Python seems to have a million different options to set up an environment. So I did what any good developer does: I asked Claude. Here's the checklist I used.
Setup
Prerequisite: you'll want to have python3 installed on your machine.
- Create a virtual environment in your current directory with
python3 -m venv .venv..venv/will be a generated folder, so add this to your.gitignore. - Activate the environment with
source .venv/bin/activate. Run this every time you open your project directory from your editor, or when you open a new terminal instance. - List all dependencies in a
requirements.txtfile. - Install dependencies with
pip install -r requirements.txt. Run this again whenever you add a new dependency to yourrequirements.txt. - Run your scripts with
python3 name.py.
Editor tooling
VS Code seems to generate helpful prompts when creating a new environment to set up editor tooling.
Outside of VS Code, I would install the pyright LSP. You can install this into neovim environments, or use the built-in pyright LSP when using Zed (my editor of choice).
To tell pyright where your python env is located, add a pyrightconfig.json with a path to your project directory (. for the current directory) and the name of your venv folder (.venv):
{
"venvPath": ".",
"venv": ".venv"
}