xxxxxxxxxx
# Install dotenv via:
pip3 install python-dotenv
# Load .env file using:
from dotenv import load_dotenv
load_dotenv()
# Use the variable with:
import os
os.getenv("ACCESS_KEY")
xxxxxxxxxx
"""
create a file in local directory
touch .env
add entries with following format:
SECRET_KEY=secret_token_here
"""
from dotenv import load_dotenv
import os
# By Default below line will load a file ".env" in current working directory
load_dotenv()
secret_key = os.getenv('SECRET_KEY')
print(secret_key)
xxxxxxxxxx
pip install -U python-dotenv
#### And in your script
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
xxxxxxxxxx
# Install dotenv via:
pip3 install python-dotenv
# Load .env file using:
from dotenv import load_dotenv
load_dotenv()
# Use the variable with:
import os
os.getenv("ACCESS_KEY")