How to set environment variables for your Python application from PyCharm
When you follow this methodology and want to run your Python application from PyCharm, you need to create a customised run configuration.
In case you need it, this post shows how to set environment variables for your Python application from PyCharm.
Creating a run configuration with environment variables
To create a run configuration with environment variables, you can follow through these screens:
While your project is selected, click on Run -> Edit Configurations...
Give your run configuration a name and click on the folder icon in the Environment Variables text input:
Click + to add a new environment variable. When you had create all the environment variables that you wish to supply to your Python application, click OK.
Click Apply then click OK to finalize your run configurations
Running or debugging your Python application with the new run configuration containing your environment variables
Once you had created your run configurations with the environment variables that you want to feed your application, you can right click on a Python script to run or debug it:
When you run or debug with the new run configurations, your Python application will be able to access the environment variables that you had created: