I tried to use the PyCharm user environment variable configuration, however, it throws KeyError. If I try to set the variables via commands it works, but via configuration it does not. I will appreciate any help.
import os print(os.environ['BLA']) (venv) (base) mikam@Mikas-MacBook-Pro Scripts % python implementVar.py Traceback (most recent call last): File "/Users/mikam/Desktop/Scripts/implementVar.py", line 2, in <module> print(os.environ['BLA']) File "/usr/local/Cellar/python@3.9/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 679, in __getitem__ raise KeyError(key) from None KeyError: 'BLA'
Advertisement
Answer
OK, apparently for terminal and run, there are different places where you define configurations.
During the whole time, I used the configurations at the top right corner, While there is another place in the terminal settings where it is also possible to configure the Terminal environment variables only.
Anyhow it solved the problem–> also necessary to restart Pycharm after adding each parameter. Hope it will help someone :)