Skip to main content

If you spend a lot of time switching between multiple Python projects and using several virtual environment, you’ll be familiar with the pain of injecting the right environment variables into your scripts. You can use autoenv, but it doesn’t automatically load the virtual environment for you, so you need to litter the .env file with bash commands. Or you can use a postactivate hook in virtualenvwrapper, but that would mean not having a standardized, default location for all the needed environment variables. And what if you use an IDE like PyCharm, which doesn’t load variables from .env files?

Envious solves the problem by loading configurations from an .env file in the working directory directly from within your Python code, injecting environment variables if they’re not already defined, while keeping those that are already set.

Installation

To install envious, simply type:

$ pip install envious

Usage

To have your project import environment variables from an .env file, first create the file in the root folder of your project:

ENVIRONMENT=development
MONGODB_URL=http://localhost:27017/mydb
REDIS_URL=http://localhost:6379/0

Then add the following to the Python app entry point:

from envious import load_env

load_env()

If you want to manage multiple configuration files for the same project, you’re covered. Create multiple configuration files, and then specify the one you want to use by providing an environment variable named ENV_FILE:

$ echo MONGODB_URL=http://localhost:27017/myseconddb > .env2
$ ENV_FILE=.env2 python my_script.py

The script will see the alternative value for the environment value MONGODB_URL.

Release files for envious 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for envious 0.3.0
File Size Uploaded
envious-0.3.0.tar.gz 2.5 kB Details

Release files / envious-0.3.0.tar.gz

Download URL envious-0.3.0.tar.gz
Size 2.5 kB
Tags Source
SHA-256 checksum
How to use checksums
06bea5bb31228ca7a15ab8ee98ee7da7bce7b3906c0d464a018a9f721b00a477
BLAKE2b-256 checksum
How to use checksums
f1b9db9729dcb3ef2ec5a3e9575b7c93b79d9b7417b2f0045e79395d6dd5fcc2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.3.0 This release

1 release file

0.2.0

1 release file

0.1.2

1 release file

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page