简体   繁体   中英

How to check wether a python-dotenv creates the environmet variable?

I am novice in IT. Sorry for possible stupid question.
I want to check wether python-dotenv really creates environment variable.
So I add.env file with my MYVAR.
Then I execute python file within code:
import dotenv; dotenv.load_dotenv(); import os; os.environ['MYVAR']
and get correct value.
But if I further check echo $MYVAR in Terminal - where is no such variable.
Is the python-dotenv really creates the env.v. or just implement its own way to parse pairs key-value?

Here's what I understand from the docu :

If your application takes its configuration from environment variables, like a 12-factor application, launching it in development is not very practical because you have to set those environment variables yourself.

To help you with that, you can add Python-dotenv to your application to make it load the configuration from a.env file when it is present (eg in development) while remaining configurable via the environment:

So dotenv will set environment variables only for the process in which it runs. The idea is to support development of applications that use environment variables. See also https://12factor.net/config .

It is not the use case for dotenv to permanently set environment variables. You would rather do that with specific tools of your operating system.

Your test confirms that setting environment variables for an application works. But the values are not set permanently. They are not visible outside the application or after it ends (and not intended to be).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM