/pyenvar

Python's .env loader

Primary LanguagePythonMIT LicenseMIT

pyenvar

Build Status

Python's .env loader is a dotenv package for Python based on https://github.com/motdotla/dotenv (dotenv module for nodejs) with zero dependency

Install

$ pip install pyenvar

Unit test

Make sure to running unit tests before pushing

$ make test

Usage

Make sure the .env file is in your project's root folder

myproject
   - src/
     - __init__.py
   - main.py
   - .env

Assumed the .env file looks like this

USERNAME=admin
PASSWORD='12345'

Basic usage

import os
import pyenvar

pyenvar.load()
print(os.environ.keys())
username = os.environ.get('USERNAME')
print(username)

Custom .env path

import os
import pyenvar

pyenvar.load(path='./config/.env', encoding='utf-8')
print(os.environ.keys())
username = os.environ.get('USERNAME')
print(username)

Pyenvar CLI

$ pyenvar-cli /path/to/.env