Python
Load secrets from .env file
Load secrets from .env file to environment variables in Python
.envenvironment
Required packages
You need below packages to use the code generated by recipe. All packages are automatically installed in MLJAR Studio.
python-dotenv>=1.0.1
Interactive recipe
You can use below interactive recipe to generate code. This recipe is available in MLJAR Studio.
Python code
# Python code will be here
Code explanation
-
Call load_dotenv() function from dotenv package.
-
You can access your variables with code:
os.environ.get("VARIABLE")
Python cookbook
Code recipes from Python cookbook.
- Previous
- Add .env variable
- Next
- Random integer