2

HI i just run over a curious thing.

In my .bashrc looks like this:

PYTHONPATH=$PYTHONPATH:/home/pschu/ParaView-3.14.1-Build/Utilities/VTKPythonWrapping/site-packages:home/pschu/ParaView-3.14.1-Build/bin

ParaView_DIR=/home/pschu/ParaView-3.14.1-Build

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/pschu/ParaView-3.14.1-Builds/bin

So now when i start the python interpreter and type following:

>>>os.environ['PYTHONPATH']
 Traceback (most recent call last):
 File "<stdin>", line 1, in <module>
 File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__
 raise KeyError(key)
KeyError: 'PYTHONPATH'

same error with ParaView_DIR, but LD_LIBRARY_PATH has the additional Path.

in the shell they exist.

echo $PYTHONPATH
:/home/pschu/ParaView-3.14.1-Build/Utilities/VTKPythonWrapping/site-packages:home/pschu/ParaView-3.14.1-Build/bin

now when i do

export PYTHONPATH=$PYTHONPATH

before I run the python interpreter it works.

What's happening?

2 Answers 2

2

This works:

% PYTHONPATH=$PYTHONPATH:/tmp python

In Python:

>>> import os
>>> os.environ["PYTHONPATH"]
':/tmp'
Sign up to request clarification or add additional context in comments.

2 Comments

What, without an export or setenv?
Yes, since the environment variable and the started python programm are on the same line. In this case no export is needed.
1

Did you export the variables?

export PYTHONPATH ParaView_DIR

LD_LIBRARY_PATH was probably already exported in one of your other startup files. Once a variable is exported it stays that way.

Exporting a variable makes it an environment variable, if you don't export then it is just local to the shell and a child process does not get a copy.

If you are using the C-shell (often indicated by the % prompt) then the syntax is different:

setenv PYTHONPATH $PYTHONPATH

Comments

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.