- How to Find the Python Installation Path on Ubuntu, Debian, or Linux Mint
- Getting the Python Installation Path Using PYTHONPATH
- Conclusion
- Where Are Python Packages Installed in Linux
- Previous Necessary Step: Learning the Installed Python Version
- Where Are Python Packages Stored When Installed Without Packages Manager
- Where Are Python Packages When Installed Through Pip
- Where Are Python Packages Installed in Debian/Ubuntu Distributions
- Where Are Python Packages Installed in Red Hat Based Distributions & SUSE
- How to Find Installed Python Packages Independently of the Installation Method
- Finding Python Modules
- Conclusion
- About the author
- David Adams
- where is python on linux?
- Similar topics
How to Find the Python Installation Path on Ubuntu, Debian, or Linux Mint
There comes a time now and again when you might want to know where your Python installation path on your Ubuntu, Debian, or Linux Mint distros is located.
Generally, by default, your Python binary is located at /usr/bin/python but it may not always be a guarantee depending on the version you are using. As you can see from this post you can actually install a different version from the default that comes with your distro.
As with the case with many things on Linux systems, there is more than one way to reliably get the Python installation path on that system.
Getting the Python Installation Path Using PYTHONPATH
You can get the value of PYTHONPATH only if it has been set. This is an environment variable that is available on the system. If it has not been set then the result of running any one of the commands below will not return anything.
If the above commands do not work you can also get the path using the which command as shown below.
$ which python /usr/bin/python
Conclusion
Once you know the path of the default Python installation path for your system you can permanently add it as an environment variable by opening the startup file you use for your default shell. This is usually ~/.profile in Ubuntu.
Open the file in your preferred editor and add the following line at the end of that file.
export PYTHONPATH=/usr/bin/python
You then need to restart your terminal to effect the change. You can also run the above on the command-line if you just need it to last the current session.
Found this article interesting? Follow Brightwhiz on Facebook, Twitter, and YouTube to read and watch more content we post.
Where Are Python Packages Installed in Linux
By reading this tutorial, you will learn where the Python packages and modules are installed in your system and other Linux distributions. But the most important teaching in this tutorial is in the last section, where you will learn how to find the Python packages without memorizing the directories independently of the Linux distribution or installation method.
All examples shown in this article include screenshots, making it easy for every Linux user to understand them independently of their knowledge level.
Previous Necessary Step: Learning the Installed Python Version
To follow all instructions described in this article, you must first know the Python version installed in your system.
To learn it, you can use the ls command followed by the executable files path and replace the version with a wildcard as shown in the following:
As you can see, there are two Python versions currently installed in my system: Python 3.9 and Python 2.7. The other paths belong to the symbolic links.
Where Are Python Packages Stored When Installed Without Packages Manager
If the Python installation was done from sources or from Python installation mechanisms (like easy_install or Python setup.py) and not from a packages manager like apt-get or aptitude among others, Python packages are stored under the /usr/local/lib/python/ directory.
This directory can be defined as universal and valid for almost every Linux distribution because it’s based on installation methods available for different distributions independently of their package managers. Of course, this is not valid when Python is installed using a specific distro packages manager.
If you compiled Python from sources or installed it using the setup.py or easy_install, you can check this location using the ls command as shown in the following screenshot where 3.10 must be replaced with your actual Python version.
Where Are Python Packages When Installed Through Pip
Python packages installed using the pip command are stored under the /usr/local/lib//dist-packages/pip/ directory.
You can find the correct location by using the pip command followed by the list option as shown in the following:
Where Are Python Packages Installed in Debian/Ubuntu Distributions
If you are a Debian, Ubuntu, or other based distribution and you installed Python through the dpkg packages manager or one of its frontends like apt-get, apt or aptitude, the packages are stored in the /usr/lib/python directory, as shown in the following image where 3.9 must be replaced with your actual Python version.
Note: As mentioned previously, if you don’t install Python using the dpkg, apt, apt-get or aptitude, the packages will have a different location described in the first section of this document.
Where Are Python Packages Installed in Red Hat Based Distributions & SUSE
Like in Debian/Ubuntu, Python packages without defined specific architecture are installed under the /usr/lib/python directory.
But specific architecture Python packages in Red Hat are stored under a descriptive directory like /usr/lib64/python .
Local Python packages are installed under /home//.local/lib/python/.
How to Find Installed Python Packages Independently of the Installation Method
Whatever is your Linux distribution, you can always use the find command to search the files by type, in this case to find the Python packages using its .py extension as shown in the following figure where /usr is the parent directory in the recursive search, -type f defines that you are searching files and not directories, and “*.py” is the extension of files that you are looking for.
Finding Python Modules
To find the Python modules, open the Python console by executing the python, where must be replaced with your actual Python version. Then, run the command help(“modules”) as shown in the following example:
In our case, using the Python 3, we execute the following code:
Then, we also execute this following code:
Conclusion
As you can see, Python packages are installed in different locations depending on the Linux distribution, installation methods, and in some cases, depending on the architecture. But the find command is useful to search all Python packages independently of the installation method, distribution, or architecture, and is a valid technique for every Linux distribution. Learning the program versions or how to find the files by type or extension is extremely easy and mandatory for all the Linux users independently of their knowledge level. It is important to clarify that while this article provides examples including Python 2, this version was discontinued and Python 3 is the current version, with many improvements. Always try to install Python using your Linux distribution packages manager, automatically resolving the dependencies and easing the removal process before problems.
Thank you for reading this article. We hope it was useful. Keep following Linux Hint for more professional Linux tips and tutorials.
About the author
David Adams
David Adams is a System Admin and writer that is focused on open source technologies, security software, and computer systems.
where is python on linux?
I installed fedora core 6 and it has python installed.
But the question is, where is the executable python file?
I can’t find it so I come here for help.
I want to config pydev for eclipse and I need to know where the
ececutable python file is.
Thank you!
tell you what you want to know?
sebastian.
I installed fedora core 6 and it has python installed.
But the question is, where is the executable python file?
Frank Potter wrote:
I installed fedora core 6 and it has python installed.
But the question is, where is the executable python file?
on linux type:
whereis python
You should get a list of directories where all of
python lives.
jim-on-linux
http:\\www.inqvista.com
On Sunday 07 January 2007 04:05, Frank Potter
wrote:
I installed fedora core 6 and it has python
installed. But the question is, where is the
executable python file? I can’t find it so I
come here for help. I want to config pydev for
eclipse and I need to know where the ececutable
python file is.
Thank you!
I installed fedora core 6 and it has python installed.
But the question is, where is the executable python file?
I can’t find it so I come here for help.
Frank Potter a �crit : >I installed fedora core 6 and it has python installed.
But the question is, where is the executable python file?
I can’t find it so I come here for help.
«A sandwich is a sandwich, but a Manwich is a meal.»
«A sandwich is a sandwich, but a Manwich is a meal.»
«A sandwich is a sandwich, but a Manwich is a meal.»
Usually «Python» is installed in /usr/lib/python[VER] but you should be
able to call up /usr/bin/python without any difficulty.
Harlin Seritt
Frank Potter wrote:
I installed fedora core 6 and it has python installed.
But the question is, where is the executable python file?
I can’t find it so I come here for help.
I want to config pydev for eclipse and I need to know where the
ececutable python file is.
Thank you!
whereis python «whereis» is cool!
This thread has been closed and replies have been disabled. Please start a new discussion.
Similar topics
Hi, If there is somebody knows where to get examples of programs in Python concerned about any specific problems? Thanks!
I have just discovered the existance of Puppy Linux which is a complete operating system with a suite of GUI apps, only about 50 — 60M booting directly off the CDROM ( http://www.puppylinux.org.
I’ve traditionally been a Java developer, although I play around with LISP. I recently migrated to Linux and I was exploring Mono as an option for development on Linux. However, I’ve had some.
As a complete novice in the study of Python, I am asking myself where this language is superior or better suited than others. For example, all I see in the tutorials are lots of examples of list.
I tried to call pydoc from my Linux box. To my realization that it doesn’t contain pydoc. I thought this module should be a default module. Can anybody suggest where can I find the module? I.
Hi All, After a disaster in which I lost my whole harddrive, I decided to install the newest everything that I use. I put the latest Gentoo Linux, with gcc 4.1.1, installed tcl/tk 8.4.14 and.
Hi All, I am trying to make a debian package. I am following the tutorial by Horst Jens (http://showmedo.com/videos/video?name=linuxJensMakingDeb&fromSeriesID=37) and it is very informative.
I’m installing Python 2.4.4 on a CentOS release 4.6 (Final) 64-bit machine. Running «./configure —prefix=»/ usr/local/yosi/ciao-4.0/ots» —enable-shared» appears to be fine, but I get the.
Hi, I try to «build» and «install» pysqlite? After I type «python setup.py build» I get a lot of error messages? The first error is «src/ connection.h:33:21: error: sqlite3.h: No such file or.
The next Access Europe meeting will be on Wednesday 7 June 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central.
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts.
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
I am a newbie to Access (most programming for that matter). I need help in creating an Access database that keeps the history of each user in a database. For example, a user might have lesson 1 sent.
I have a table that can contain up to 12 entries for an individual in the number field each number can be different number I want only to add up the top 7 numbers for each individual. What’s the.
Ⅱ. Download AntDB Community Version Download at: http://www.antdb.net/download, choose X86 version under Open Euler https://img1.imgtp.com/2023/06/14/hn1P9Kz2.png Ⅲ. Deploy AntDB Community.
What is the best, comprehensive Reference for programming Windows Applications in VB.NET. I have experience in programming in general, but not VB.NET. Thanks in advance.
I have been asked to publicise the next meeting of the UK Access User Group which will be on Thur 22 June from 16:00 to 17:30 UK time (UTC+1) The meeting is free and open to all (both members and.
The next Access Europe meeting will be on Wednesday 5 July 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central.
By using Bytes.com and it’s services, you agree to our Privacy Policy and Terms of Use.
To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.