How do I set environment variables in virtual environment creating by UV? I try setting it in .venv/scripts/activate_this.py and it doesn't work.
You can tell the uv run command to load environment variables from a file, either by using the --env-file option:
uv run --env-file=.env myscript.py
Or by setting the UV_ENV_FILE environment variable:
export UV_ENV_FILE=.env
uv run myscript.py
You will find more details in the documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With