0

I have the following in my shell script ,i have a python version present in /prj/qct/asw/SA/Linux which is overwriting the default one /usr/bin/python,how do I ensure python version is picked from /usr/bin/python with still exporting the KWTOOLS_DIR ?

export KWTOOLS_DIR=${KWTOOLS_DIR:-"/prj/qct/asw/SA/Linux"}
export PATH=${KWTOOLS_DIR}/Klocwork/Server/bin:$PATH 

1 Answer 1

1

You can ensure that the path of your python installation appears earliest in the PATH,

export KWTOOLS_DIR=${KWTOOLS_DIR:-"/prj/qct/asw/SA/Linux"}
export PATH=$PATH:${KWTOOLS_DIR}/Klocwork/Server/bin 

or you could use environment management tools such as virtualenv. I'd suggest the latter as it helps you isolate your python installations and the various dependency sets you might have for a given python install or version.

You can also start your individual scripts with the version you want to use:

#! /usr/bin/python

More detail on that route is here

other questions posed slightly differently but that might have the same answers:

regarding usr/bin/env

usage of #!

more usage of #!

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

5 Comments

how to ensure the path of your pythoninstallation appears firt..can we do export on the path before the KWTOOLS_DIR ?please suggest exact script changes
edited with script adjustment. append to end instead.
this super user question might be helpful as well: superuser.com/questions/238987/…
willthe following work?export KWTOOLS_DIR=${KWTOOLS_DIR:-"/prj/qct/asw/SA/Linux"} export PATH=$PATH:${KWTOOLS_DIR}/Klocwork/Server/bin export PATH=$PATH:/usr/bin/python
I'm not sure why you're trying to append /usr/bin/python to the end of the path; /usr/bin should already be on your path. And if it wasn't then this puts /usr/bin/python after the KWTOOLS_DIR.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.