I have a few problems regarding the use of .bash_profile.bash_profile and Pycharm. I am using mac OS X. I created a new project on pycharm with new environment using virtualenv with base interpreter /usr/local/bin/python3.5/usr/local/bin/python3.5.
STEP 1: I then accessed the .bash_profile from my mac OS terminal and exported 2 variables: DB_USERDB_USER and DB_PASSDB_PASS as "my_db_user"my_db_user and "my_db_pass"my_db_pass respectively.
STEP 2: Using Pycharm, I imported os and then proceeded to print out the 2 variables using os.environ.get()os.environ.get(). Running the .py file using pycharm (F10) returns "my_db_user"my_db_user and "my_db_pass"my_db_pass.
As I decided to create 2 new variables "test user"test user and "test pass"test pass in the virtual environment, I proceeded to activate my venv (venv/bin/activatevenv/bin/activate) in the shell of pycharm. Then, I removed the changes I did in STEP 1.
However, running the .py using pycharm (F10) STILL returns "my_db_user"my_db_user and "my_db_pass"my_db_pass instead of "test user"test user and "test pass"test pass (I have already removed "my_db_user"my_db_user and "my_db_pass"my_db_pass so I have no idea where it is coming from!). On top of that, when I run the python file on the shell using python test.py, it returns (None, None) instead of my desired "test user"test user and "test pass"test pass.
I need help to sort this out so that os.environ.get()os.environ.get() returns my desired output. One possible reason is that I might be confused on how pycharm, shell in pycharm and terminals are interacting. Please help thanks!
import os user = os.environ.get('DB_USER') password = os.environ.get('DB_PASS') print(user,password)