4 examples of 'load_dotenv' in Python

Every line of 'load_dotenv' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
5def load_env():
6 "Get the path to the .env file and load it."
7 project_dir = dirname(dirname(__file__))
8 dotenv.read_dotenv(join(project_dir, '.env'))
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

7def _load_environment():
8 try:
9 # noinspection PyUnresolvedReferences
10 from dotenv import load_dotenv
11 load_dotenv(join(dirname(__file__), '.env'))
12 except ImportError:
13 pass
15def load_dotenv(dotenv_path=None, stream=None, verbose=False, override=False):
16 f = dotenv_path or stream or find_dotenv(usecwd=True)
17 return DotEnv(f, verbose=verbose).set_as_environment_variables(override=override)
20def _load_environment(app: Flask) -> None:
21 try:
22 # noinspection PyUnresolvedReferences
23 from dotenv import load_dotenv
24 load_dotenv(join(app.root_path, '..', '..', '.env'))
25 except ImportError:
26 pass

Related snippets