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.
Hello, I developed a python software but I do not know where should I place it in the linux filesystem, in order to be able to run it from any command line. I do not want to use alias to do that, is there a sort of bin folder in the user directory where should I place my project?
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>
I've installed python before on my main PC I installed it in /bin/sh.... that's something I didn't do on my laptop and now my program(geany) is looking for python in /bin/sh. How to fix this?
Use which python.
- which man page
$ which python
/usr/bin/python
C:\Users\anossovp>where python
c:\Python27\python.exe
The thing you are usually looking for is not where Python itself is, but where it's libraries are. For that I would recommend this:
(from within the Python shell)
import sys
import pprint
pprint.pprint(sys.path)
Outside of that you can still do which python naturally.