P P
P P

Reputation: 137

PYTHONPATH is not working for multiple path

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

Upvotes: 1

Views: 6037

Answers (1)

jdi
jdi

Reputation: 92657

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.

Upvotes: 2

Related Questions