Python is one of the most popular and versatile programming languages in the world. You can use Python for web development, data analysis, machine learning, automation, and more. Before you can start using Python, you need to know where it is installed on your computer.
How to Check Where is Python Installed
The easiest way to check if Python is installed on your computer is to open a command prompt or terminal and type python --version
. This will show you the version of Python that is currently available on your system. For example, you might see something like this:
python --version
Python 3.9.4
If you see a message like python: command not found
or python is not recognized as an internal or external command
, then it means that Python is not installed or not added to your system path.
How to Install Python
If you don’t have Python installed on your computer, you can download it from the official website. There are different versions of Python available, but the latest one as of November 2023 is Python 3.10.0. You can choose the installer that matches your operating system and follow the instructions to install Python. Installing Python also installs pip, a tool for installing and managing Python packages.
Python packages are collections of code that provide additional functionality for Python. For example, you can use pip to install packages like numpy, pandas, matplotlib, and more.
Read More From The Teksol: Belatrix Software
How to Find Python Installation
After you install Python, you might want to know where it is located on your computer. This can be useful for various reasons, such as setting up your development environment, configuring your system path, or accessing Python files and folders. To locate the Python installation, please inspect your operating system. There are different ways to do it, depending on which operating system you are using. Here are some common methods:
#1- Windows
You can use the where
command in the command prompt to find where Python
is installed. For example, if you type where python, you might see something like this:
where python
C:\Users\username\AppData\Local\Programs\Python\Python310\python.exe
C:\Users\username\AppData\Local\Microsoft\WindowsApps\python.exe
The first line shows the location of the Python executable that you installed from the official website. The second line shows the location of the Python executable that comes with Windows 10. You can also use the py
command instead of python
to launch the latest version of Python on your system.
#2- MacOS
You can use the which
command in the terminal to find where Python is installed. For example, if you type which python
, you might see something like this:
which python
/usr/bin/python
This shows the location of the default Python executable that comes with MacOS. However, this might not be the same as the Python executable that you installed from the official website. To find that, you can use the python3
command instead of python
and then use the -m site
option to show where the Python modules are stored. For example, if you type python3 -m site
, you might see something like this:
python3 -m site
sys.path = [/Users/username',
'/Library/Frameworks/Python.framework/Versions/3.10/lib/python310.zip',
'/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10',
'/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/lib-dynload',
'/Users/username/Library/Python/3.10/lib/python/site-packages',
'/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages',
]
USER_BASE: /Users/username/Library/Python/3.10
(exists)
USER_SITE: /Users/username/Library/Python/3.10/lib/python/site-packages'
(exists)
ENABLE_USER_SITE: True
The first line shows your current working directory. The second and third lines show the location of the Python executable and library that you installed from the official website.
The fourth line shows the location of the built-in modules that come with Python. The fifth and sixth lines show the location of the user-installed packages that you installed with pip. The last three lines show some additional information about your user site.
#3- Linux
You can find Python on Linux using the same commands as macOS. However, depending on your Linux distribution and how you installed Python, you might see different results. For example, if you use Ubuntu and install Python from the official website, you might see something like this:
which python
/usr/local/bin/python
python3 -m site
sys.path = ['/home/username',
'/usr/local/lib/python310.zip',
'/usr/local/lib/python3.10',
'/usr/local/lib/python3.10/lib-dynload',
'/home/username/.local/lib/python3.10/site-packages',
'/usr/local/lib/python3.10/site-packages',
]
USER_BASE: '/home/username/.local'
(exists)
USER_SITE: '/home/username/.local/lib/python3.10/site-packages'
(exists)
ENABLE_USER_SITE: True
The first line shows the location of the Python executable that you installed from the official website. The second and third lines show the location of the Python executable and library that you installed from the official website.
The fourth line shows the location of the built-in modules that come with Python. The fifth and sixth lines show the location of the user-installed packages that you installed with pip. The last three lines show some additional information about your user site.
Conclusion
This article teaches you how to check, install, and find Python on different operating systems. We have also learned some useful commands and tools to work with Python and its packages. This article has hopefully assisted you in commencing your journey with Python, allowing you to appreciate its incredible features and capabilities. Happy coding with The Teksol!