2

In Centos 7 system, what is the default pythonpath enviroment? Before I make any pythonpath setting, the command "echo $PYTHONPATH" gives no output. After I make the following setting:

PYTHONPATH="{$PYTHONPATH}:/usr/lib/python2.7/site-packages:/usr/lib64/python2.7/site-packages/pandas:/app/anaconda2/pkgs"
export PYTHONPATH=$PYTHONPATH:/app/Jade

the command "echo $PYTHONPATH" gives the following output:

:/app/Jade

I don't understand why before "/app/Jade" there is an extra colon (:). And what is the correct way to set PYTHONPATH?

Best regards.

Yeping Sun

3
  • If it's not defined, why are you trying to use it in the first line ? Commented Aug 19, 2017 at 2:04
  • {$PYTHONPATH} is an error. That would result in an invalid path containing literal { and } characters. I think you mean ${PYTHONPATH}. Commented Aug 19, 2017 at 2:15
  • But to you question: I cannot think of any way in which the two lines you have in your question would result in the behavior you are seeing (provided that these lines and your echo command all happen in the same shell). Are you sure the commands you are typing match exactly what you have posted here? What happens if you copy and paste? Commented Aug 19, 2017 at 2:16

2 Answers 2

2
export PYTHONPATH=/usr/lib/python2.7/site-packages:/usr/lib64/python2.7/site-packages/pandas:/app/anaconda2/pkgs:/app/Jade

The problem is in your first one, you included "" around $PYTHONPATH.

Secondly, the correct way to do this is:

export PATH=$PATH:/path/to/python

You can do which python to figure out what your path to Python is.

And then simply to export PYTHONPATH=/app/Jade <-- this may be incorrect as well since you need to supply this with an absolute path. Unless app is in your root folder, this won't work.

ALSO if you could copy-paste the exact error you are getting, that would be really helpful to the SO community in helping you, with this post and future posts.

Sign up to request clarification or add additional context in comments.

Comments

1

This has nothing to do with $PYTHONPATH but is a more generally PATH naming scheme. PATH is a colon-seperated list. From What is path?

Thus, for example, to add a directory named /usr/test to a user's PATH variable, it should be appended with a text editor to the line that begins with PATH so that the line reads something like PATH=$PATH:$HOME/bin:/usr/test. It is important that each absolute path be directly (i.e., with no intervening spaces) preceded by a colon.

See more here: Python - PYTHONPATH in linux

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.