24

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 Dec 6, 2013 at 12:37
2
  • 1
    printenv PYTHONPATH? Commented Dec 6, 2013 at 12:41
  • You question is not very clear, do you want to see the variable in the terminal or in python? You've got both answers below, but you should make the question clearer. Commented Dec 6, 2013 at 12:49

4 Answers 4

38

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

Thirumal
9,99416 gold badges71 silver badges121 bronze badges
answered Oct 15, 2018 at 5:20
Sign up to request clarification or add additional context in comments.

Comments

15

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 Dec 6, 2013 at 12:46

1 Comment

Ya it was bad example to use /etc .
11

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

answered Dec 6, 2013 at 12:46

Comments

4

Command:

which python

gives path to python

as:

which python3

gives python3 path

answered Sep 1, 2022 at 20:11

1 Comment

This is not the PYTHONPATH environment variable as is referred to in the question

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.