1

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

2
  • 1
    You're trying to use cd to go to multiple paths? Don't do that. Commented May 15, 2012 at 22:52
  • What does the cd command have to do with your PYTHONPATH? Commented May 15, 2012 at 23:07

1 Answer 1

2

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.

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

4 Comments

Thank you jdi for directing me, well my bad for cd. But still I get the same error <br/>Could not find platform independent libraries <prefix> Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] 'import site' failed; use -v for traceback Traceback (most recent call last): File ImportError: No module named os MsgNak received - resending Remote target is little-endian
@ParthPandya: This is a completely new problem then. Why are you setting your standard python path explicitly? That gets set when you start the python interp. PYTHONPATH is for you to add extra package locations.
well I was getting the same error before, so I though let me set python path for specific directory where located !
@ParthPandya: You need to update your question with more specifics about what you are doing. I don't think its clear at this point.

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.