To read from .env file and put it into os.environ. This project is based on https://github.com/theskumar/python-dotenv
Install
$ pip install -e git+https://github.com/aongko/py_dotenv@master#egg=py_dotenv-0
Clone this project, run:
$ python3 setup.py install
Example
Assuming you have an .env file alongside your main module.
. ├── .env └── main.py
The code would look like this:
import os
from py_dotenv import read_dotenv
dotenv_path = os.path.join(os.path.dirname(__file__), '.env')
read_dotenv(dotenv_path)
Let’s assume your .env file looks like this:
APP_DEBUG = TRUE
CUSTOM_CONFIGURATION = ABC
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'
Metadata
Release files for py-dotenv 0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_dotenv-0.1-py3-none-any.whl | Python 3 | none | any | Details for py_dotenv-0.1-py3-none-any.whl |
Release files / py_dotenv-0.1-py3-none-any.whl
| Download URL | py_dotenv-0.1-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
548c588c3b7e2ee2142b0ac97d2912d223ff38e874302426bbb6c21353817cc2
|
|
BLAKE2b-256 checksum How to use checksums |
5e3a32e68bcdf9419611af95be030bb724c1a40f72bc9b62be28b9c1a08217b2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for py-dotenv 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.