---
title: "Local Development: Python"
description: "Run Django, FastAPI, Flask and Python scripts locally with secrets from Ennote instead of a .env file, using ennote secret get with python, uv, Poetry or a Makefile."
canonical_url: "https://docs.ennote.io/guides/local-development/python"
---
# Local Development: Python

> Run Django, FastAPI, Flask and Python scripts locally with secrets from Ennote instead of a .env file, using ennote secret get with python, uv, Poetry or a Makefile.

Put `ennote secret get "<secret>" --` in front of the command that starts your app. Python reads the values with `os.environ`, like any environment variable.

The examples use a secret named `api-env`. Set your organization and workspace once with [`ennote config set`](https://docs.ennote.io/cli/commands/config), or add `--organization-id` and `--workspace-id` flags as in the [overview](https://docs.ennote.io/guides/local-development/overview#sharing-the-command-with-your-team).

## Reading Values

```python [settings.py]
import os

DATABASE_URL = os.environ["DATABASE_URL"]       # required: fails fast if missing
DEBUG = os.environ.get("DEBUG", "false") == "true"  # optional, with a default
```

All values arrive as strings. Convert numbers and booleans yourself, or use a settings library such as Pydantic Settings, which reads environment variables and validates types:

```python [config.py]
from pydantic_settings import BaseSettings

class Settings(BaseSettings):
    database_url: str
    stripe_secret_key: str
    debug: bool = False

settings = Settings()  # reads DATABASE_URL, STRIPE_SECRET_KEY, DEBUG
```

## Django

```bash
ennote secret get "api-env" -- python manage.py runserver
```

Migrations and other management commands need the same variables:

```bash
ennote secret get "api-env" -- python manage.py migrate
```

## FastAPI

```bash
ennote secret get "api-env" -- uvicorn main:app --reload
```

Or with the FastAPI CLI: `ennote secret get "api-env" -- fastapi dev main.py`.

## Flask

```bash
ennote secret get "api-env" -- flask --app app run --debug
```

## Scripts and Notebooks

```bash
ennote secret get "api-env" -- python scripts/sync_customers.py
ennote secret get "api-env" -- jupyter lab
```

Every notebook kernel started from that Jupyter server sees the variables.

## uv and Poetry

Put Ennote first, then the tool that runs your code:

```bash
ennote secret get "api-env" -- uv run uvicorn main:app --reload
ennote secret get "api-env" -- poetry run python manage.py runserver
```

## Saving the Command in a Makefile

Python has no `package.json` scripts, so a `Makefile` is a common place to share the command with your team:

```makefile [Makefile]
ENNOTE = ennote secret get "api-env" --organization-id "my-org-id" --workspace-id "local-development" --

dev:
    $(ENNOTE) uvicorn main:app --reload

migrate:
    $(ENNOTE) alembic upgrade head
```

Run `make dev` or `make migrate`.

## Keeping python-dotenv

If your code calls `load_dotenv()`, you can leave it in place. By default it does not override variables that are already set, so the values from Ennote win, and it does nothing when no `.env` file exists.

<need-help>



</need-help>


## Sitemap

See the full [sitemap](https://docs.ennote.io/sitemap.md) for all pages.
