1

I have my ~/.bashrc file:

PATH=$PATH:/usr/pgsql-9.3/bin/

DB_USER=postgres
DB_PASSWORD=password
DB_HOST=localhost

When I'm doing os.environ['PATH'] I get :

/usr/local/sbin

But when I'm doing os.environ['DB_USER'] I get:

KeyError: 'DB_USER'

How I need to declare my vars correctly for python, cause echo in shell :

echo $DB_USER
    >>> postgres

thanx

2 Answers 2

5

You haven't exported your variables:

export DB_USER=postgres
export DB_PASSWORD=password
export DB_HOST=localhost
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, i think this is a solution!
0

if you get /usr/local/sbin from os.environ['PATH'] this is an indication your .bash.rc did not run since you change the PATH there in the first line.

Any chance you did not restart bash before checking this?

1 Comment

i made source ~/.bashrc

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.