1
votes

I want to set pythonpath, but it doesnt work for other directory.

My bashrc:

export PYTHONPATH=/usr/lib/python2.7
export PYTHONPATH=$PYTHONPATH/plat-linux2:$PYTHONPATH/lib-dynload:$PYTHONPATH/dist-packages:$PYTHONPATH/lib-tk:$PYTHONPATH

If I keep only first line(single directory)
export PYTHONPATH=/usr/lib/python2.7
then, my bash shell takes me to the /usr/lib/python2.7 directory.

But when I include multiple directory -
export PYTHONPATH=$PYTHONPATH/plat-linux2:$PYTHONPATH/lib-dynload:$PYTHONPATH/dist-packages:$PYTHONPATH/lib-tk:$PYTHONPATH
It throws error like bash: cd: /usr/lib/python2.7/plat-linux2:/usr/lib/python2.7/lib-dynload:/usr/lib/python2.7/dist-packages:/usr/lib/python2.7/lib-tk:/usr/lib/python2.7: No such file or directory

1
You're trying to use cd to go to multiple paths? Don't do that.Mark Ransom
What does the cd command have to do with your PYTHONPATH?jdi

1 Answers

2
votes

Don't use PYTHONPATH to construct more joined paths. Use some temp variable.

PY_BASE=/usr/lib/python2.7

PYTHONPATH=$PY_BASE:$PY_BASE/plat-linux2:$PY_BASE/lib-dynload
PYTHONPATH=$PYTHONPATH:$PY_BASE/dist-packages:$PY_BASE/lib-tk
export PYTHONPATH

Also, the cd command has nothing to do with the PYTHONPATH. Meaning you are doing something completely unrelated to try and cd into your PYTHONPATH.