Try:
which python
in a terminal.
Answer from icyrock.com on Stack OverflowTry:
which python
in a terminal.
For this very reason it is recommend that you change your shebang line to be more path agnostic:
#!/usr/bin/env python
See this mailing list message for more information:
Consider the possiblities that in a different machine, python may be installed at
/usr/bin/pythonor/bin/pythonin those cases,#!/usr/local/bin/pythonwill fail. For those cases, we get to call theenvexecutable with argument which will determine the arguments path by searching in the$PATHand use it correctly.(
envis almost always located in/usr/bin/so one need not worry thatenvis not present at/usr/bin.)
Hi, I have anaconda installed, so typing:
which python
just returns the anaconda path, however, I need to unearth the standard install location as a script is annoyingly asking for python2.7. Google unfortunately only tells you how to install it, and I know that, I've just forgotten where the binary is usually located on linux and google won't tell me that no matter what I type in.
UPDATE: Thanks guys, I found it looking in /usr/bin/ and /usr/local/bin/ and to my delight, it's not there, Just upgraded to Linux Mint 20 and there is python3.8. lovely.
Python Installation
Python 3 install location - Stack Overflow
python installed but I can't find it
How do I know python path on linux ubuntu? - Stack Overflow
Videos
First question:
which python though its usually /usr/bin/python for the 2.7
Second question:
From a terminal & python2.7: python2.7 yourfile.py.
Simailarly for 3.2: python3.2 yourfile.py though 3.2 isn't installed by default. (You can apt-get install python3.2.)
What python yourfile.py will do depends on which alternative is used for your python interpreter. You can change that by issuing update-alternatives python as root (or by using su).
Third question:
Environment variables are shell dependent, though you can write them out with echo $variable and set them with variable=value (from bash). The search path is simply called PATH and you can get yours by typing echo $PATH.
I hope this was helpful.
If you want to find the location of a program you can just use whereis <program>.
In your case run:
whereis python2.7
whereis python3.2
For finding every file that apt-get has copied for installation use:
dpkg -S python2.7
dpkg -S python3.2
But maby it is recommend to save it in a textfile, because the output is to large.
dpkg -S python2.7 >log.txt
gedit log.txt
for running .py file with python 3.2
python3.2 <file.py>
You can type which python on the ubuntu terminal and it will give the Python installed location path.
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.