If you use pipenv or dotenv in Python, you can use the .env
file of project dir. You can read it and set environment variables. Often, you can control the behavior of your environment by writing the .env
file in .gitignore
so that you don't commit.
I love PyCharm, but I didn't know how to get this .env
loaded when running from the IDE. However, I finally found it the other day, so I will write it down.
First, open Run Configuration.
Open the ʻEnvFile tab and check ʻEnable EnvFile
.
Press +
to select .env file
.
I think that if you choose this, you're done. However, files that start with .
like .env
are not displayed in the dialog ... I don't feel that I can get them out even if I operate them properly. So I will devise one.
I will create a symlink in project_dir.
% ln -s .env dot.env
When you open the previous dialog again, the dot.env
file is increasing, so select it.
Then you will be able to add it safely.
The contents are also reflected properly.
After reflecting it in the IDE, you can delete the symlink.
% rm dot.env
It's less stressful because you don't have to manually set and update it every time. Well, maybe everyone is inconvenient, so I think it will be improved within a year ...
Recommended Posts