PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 19, 2022

[FIXED] Why PyCharm does not recognize user environment variables configuration?

 August 19, 2022     environment-variables, keyerror, pycharm, python, python-3.9     No comments   

Issue

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'




Solution

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 :)



Answered By - MikaM
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing