You can set environmental variables in Pycharm’s run configurations menu.
- Open the Run Configuration selector in the top-right and cick
Edit Configurations...

- Select the correct file from the menu, find
Environmental variablesand click...

- Add or change variables, then click
OK

You can access your environmental variables with os.environ
import os
print(os.environ['SOME_VAR'])