How do I know python path on linux ubuntu?

Question:

In ubuntu linux if we want to set up python path we do something like this:

export PYTHONPATH=/etc ...

Now, how I would know what the current path I have?

Asked By: Mero

||

Answers:

First, I hope you don’t really set PYTHONPATH=/etc, /etc is for configuration files, not python libraries.

You can see what an environment variable is set to by using echo, e.g.: echo $PYTHONPATH. If the variable has not been set it will be blank. You can also use env to get a list of all environment variables, and couple with grep to see if a particular one is set, e.g. env | grep PYTHONPATH.

Answered By: aquavitae

use printenv command, it will print all the environment variables,
to only print PYTHONPATH use:
printenv PYTHONPATH

Answered By: hmd.ai

You can type which python on the ubuntu terminal and it will give the Python installed location path.

Answered By: Aashish Ranjan

Command:

which python

gives path to python

as:

which python3

gives python3 path

Answered By: ShefSam
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.