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.

Answer from Wolfer on askubuntu.com
🌐
Reddit
reddit.com › r/learnpython › where is python installed on linux
r/learnpython on Reddit: Where is python installed on Linux
February 10, 2021 -

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.

Discussions

Python Installation
Hello, I recently got python downloaded in my system. able to open all terminals, Idle windows able to access Pycharm. but really not sure where is the exact location of Python installed when i try to check from Command prompt. I wanted to add Environmental Variables. Please help. More on discuss.python.org
🌐 discuss.python.org
5
0
December 7, 2023
python - Use another site-packages directory by default for setup.py install - Stack Overflow
This location varies by platform and by how you built/installed Python itself. Most Linux distributions include Python as a standard part of the system, so prefix and exec-prefix are usually both /usr on Linux. If you build Python yourself on Linux (or any Unix-like system), the default prefix ... More on stackoverflow.com
🌐 stackoverflow.com
October 13, 2017
Python 3 install location - Stack Overflow
I am using Ubuntu 16.04 . Where is the python 3 installation directory ? Running "whereis python3" in terminal gives me: python3: /usr/bin/python3.5m-config /usr/bin/python3 /usr/bin/python3.... More on stackoverflow.com
🌐 stackoverflow.com
How to change default install location for python? - Stack Overflow
I am using RedHat Linux. Python 2.6 is already installed in usr/src/bin. When I install Python 2.7, it gets installed in usr/local/src/bin. Further, I need to install sklearn. When I try installing sklearn using pip, it refers to Python2.6 and not Python2.7. ... I think you can probably specify the location ... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How do I find where Python installs packages?
Run the site module through the interpreter used by your program. On Windows use python -m site, and on macOS or Linux use python3 -m site.
🌐
askpython.com
askpython.com › python › examples › find-where-python-is-installed
Where Is Python Installed? Find Its Path - AskPython
Does sys.executable show the virtual environment's Python?
When Python runs inside a virtual environment, sys.executable points to that environment's interpreter. sys.base_prefix identifies the base installation prefix.
🌐
askpython.com
askpython.com › python › examples › find-where-python-is-installed
Where Is Python Installed? Find Its Path - AskPython
Is where.exe python the same as sys.executable?
where.exe searches the current directory and PATH for matching files. sys.executable reports the executable running the current Python process.
🌐
askpython.com
askpython.com › python › examples › find-where-python-is-installed
Where Is Python Installed? Find Its Path - AskPython
🌐
LinuxVox
linuxvox.com › blog › where-is-python-installed-linux
Where is Python Installed on Linux: A Comprehensive Guide — linuxvox.com
Most Linux distributions come with a system-wide Python installation. This is usually located in directories like /usr/bin or /usr/local/bin.
🌐
Python
docs.python.org › 3.3 › install › index.html
Installing Python Modules — Python 3.3.7 documentation
September 19, 2017 - If you build Python yourself on Linux (or any Unix-like system), the default prefix and exec-prefix are /usr/local. The default installation directory on Windows was C:\Program Files\Python under Python 1.6a1, 1.5.2, and earlier.
🌐
Python
docs.python.org › 3 › using › unix.html
2. Using Python on Unix platforms — Python 3.15.2 documentation
Getting and installing the latest version of Python: On Linux: Python comes preinstalled on most Linux distributions, and is available as a package on all others. However there are certain features...
Find elsewhere
🌐
Linux Hint
linuxhint.com › python-packages-installed-linux
Where Are Python Packages Installed in Linux – Linux Hint
different location described in the first section of this document. Like in Debian/Ubuntu, Python packages without defined specific architecture are installed under the /usr/lib/python<version> directory. But specific architecture Python packages in Red Hat are stored under a descriptive directory ...
🌐
AskPython
askpython.com › python › examples › find-where-python-is-installed
Where Is Python Installed? Find Its Path - AskPython
1 month ago - An IDE or a full-path launch can still start an interpreter outside those locations. Use sys.executable to identify the interpreter running the process, and run the site module with that same interpreter to inspect its library directories. In Windows Command Prompt or PowerShell, use python. In a macOS or Linux shell, use python3.
🌐
AskPython
askpython.com › python › examples › determine-install-path-of-python-cli
Determining the Install Path of Python from the Command Line - AskPython
June 30, 2023 - The python os module and the systems module(sys) are modules that are in built and comes preinstalled with the default Python installation. They help us interact with the operating system via Python code. You can also import them and run commands to find the location of the Python executable file on your computer in the following way:
🌐
Python.org
discuss.python.org › python help
Python Installation - Python Help - Discussions on Python.org
December 7, 2023 - Hello, I recently got python downloaded in my system. able to open all terminals, Idle windows able to access Pycharm. but really not sure where is the exact location of Python installed when i try to check from Command prompt. I wanted to add Environmental Variables. Please help.
🌐
Quora
quora.com › How-can-I-find-where-Python-is-installed-on-Linux
How to find where Python is installed on Linux - Quora
Answer (1 of 19): It depends on what you mean by “installed.” The binary can be located with the which command, but you might also care where components of the python library are. You can run your version of python and type: [code]import sys sys.path [/code]On my system, I get: [code]['', ...
Top answer
1 of 2
4

There are few things you need to take care for in order to do this. I did some research, and this is what I've found out:

This part is taken from Python's docs:

After the build command runs (whether you run it explicitly, or the install command does it for you), the work of the install command is relatively simple: all it has to do is copy everything under build/lib (or build/lib.plat) to your chosen installation directory.

If you don’t choose an installation directory—i.e., if you just run setup.py install—then the install command installs to the standard location for third-party Python modules. This location varies by platform and by how you built/installed Python itself.

Most Linux distributions include Python as a standard part of the system, so prefix and exec-prefix are usually both /usr on Linux. If you build Python yourself on Linux (or any Unix-like system), the default prefix and exec-prefix are /usr/local.

prefix and exec-prefix stand for the directories that Python is installed to, and where it finds its libraries at run-time.

You have a way for alternating the install location, up to a certain point: you can alternate the base dir, but not the installation scheme

The Distutils install command is designed to make installing module distributions to an alternate location simple and painless. The basic idea is that you supply a base directory for the installation, and the install command picks a set of directories (called an installation scheme) under this base directory in which to install files. The details differ across platforms, so read whichever of the following sections applies to you.

The idea behind the “home scheme” is that you build and maintain a personal stash of Python modules. This scheme’s name is derived from the idea of a “home” directory on Unix, since it’s not unusual for a Unix user to make their home directory have a layout similar to /usr/ or /usr/local/. This scheme can be used by anyone, regardless of the operating system they are installing for.

python setup.py install --home=<dir>

The --home option defines the installation base directory. Files are installed to the following directories under the installation base as follows:

modules home/lib/python
scripts home/bin
data    home
C headers   home/include/python/distname

Then you'll need to modify Python's search path in order to locate the new location.

You can also use --prefix option which defines the installation base python setup.py install --prefix=. Read more about it here


To sum it up, you can change the home directory, but the site-packages hierarchy will be built in it.

2 of 2
1

To add new site-packages directory add that new directory path to the path configuration file.

The path configuration file will let you add an additional site-packages directory. If you don't want existing site-packages directory you can remove it from the PYTHON_PATH.

echo "new_site-package_directory" > your_site_packages_path/usrlocal.pth

🌐
Yasoob Khalid
yasoob.me › 2013 › 07 › 30 › python-install-location-and-version
Python install location and version - Yasoob Khalid
July 29, 2013 - On linux just type these two commands in the terminal: # for python install path root@bt:/$ which python /usr/bin/python # for python version; root@bt:/usr/bin$ python -V Python 2.7.5 · On windows type this commands in the command prompt for python version: ... This comes in handy when you need to know the version and path of python real quick.
🌐
Swaroopch
python.swaroopch.com › installation.html
Installation · A Byte of Python
CAUTION: Make sure you check option Add Python 3.5 to PATH. To change install location, click on Customize installation, then Next and enter C:\python35 (or another appropriate location) as the install location.
🌐
Ffy00
ffy00.github.io › blog › 02-python-debian-and-the-install-locations
Filipe Laíns - Python, Debian, and the install locations
March 30, 2026 - The site packages directory is a place for user-installed packages, it is a mechanism that that Python us to customize the default environment of the interpreter. That means packages installed there will be available in the interpreter, so you will be able to import them. This functionality is provided by the site module, and can be disabled by passing the -S option to the interpreter. Install locations on Linux are governed by the Filesystem Hierarchy Standard (FHS) specification, at least in the distributions that adopt it, which are most of them, including Debian.
🌐
Reddit
reddit.com › r/linuxmint › how to find out where i installed python 3.9?
r/linuxmint on Reddit: How to find out where I installed python 3.9?
November 26, 2020 -

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?