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?
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
.
use printenv command, it will print all the environment variables,
to only print PYTHONPATH use:
printenv PYTHONPATH
You can type which python
on the ubuntu terminal and it will give the Python installed location path.
Command:
which python
gives path to python
as:
which python3
gives python3 path
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?
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
.
use printenv command, it will print all the environment variables,
to only print PYTHONPATH use:
printenv PYTHONPATH
You can type which python
on the ubuntu terminal and it will give the Python installed location path.
Command:
which python
gives path to python
as:
which python3
gives python3 path