Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Read dotenv file

Project Description

To read from .env file and put it into os.environ. This project is based on


$ pip install -e git+

Clone this project, run:

$ python3 install


Assuming you have an .env file alongside your main module.

├── .env

The code would look like this:

import os
from py_dotenv import read_dotenv

dotenv_path = os.path.join(os.path.dirname(__file__), '.env')

Let’s assume your .env file looks like this:


After running the code above, you now can access the environment variable like this:

assert os.getenv('APP_DEBUG') == 'TRUE'
assert os.getenv('CUSTOM_CONFIGURATION') == 'ABC'
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
py_dotenv-0.1-py3-none-any.whl (3.6 kB) Copy SHA256 Checksum SHA256 py3 Wheel Dec 13, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting