Star on GitHub - 5.8k

uv

Encrypt a .env file in a Python uv project with the Dotenvx SDK, commit it safely, and load its secrets at runtime.

Prerequisites

To get the most out of this guide, you’ll need to:

Setup

Create a uv project.
$ uv init hello-world
$ cd hello-world

Install

Get the Dotenvx Python SDK.
$ uv add python-dotenvx
And the CLI to encrypt files.
$ curl -sfS https://dotenvx.sh | sh

Encrypt

Encrypt your .env file.

$ dotenvx encrypt

Inject

Then inject your encrypted secrets at runtime.
import os
from dotenvx import load_dotenv

load_dotenv()

print(f"HELLO: {os.getenv('HELLO')}")
Run it with uv.
$ uv run main.py