How To Check If Python Is Installed On Windows & Mac

You can check if Python is installed on your computer by using the command line (or terminal on macOS and Linux, or Command Prompt on Windows). Here’s how to do it:

For Windows:

  1. Open the Command Prompt.
    • You can do this by searching for “Command Prompt” in the Windows search bar and clicking on it.
  2. Type the following command and press Enter:
python --version
Code language: Python (python)

If Python is installed, this command will display the installed Python version. For example, it might show something like “Python 3.8.5.”

For macOS and Linux:

  1. Open the Terminal.
    • You can typically find the Terminal application in your Applications folder on macOS, or by searching for it in the applications menu on Linux.
  2. Type the following command and press Enter:
python --version
Code language: Python (python)
  1. If Python is installed, this command will display the installed Python version, similar to what’s shown above.

Alternatively, if you want to check if Python is installed and also find out where it’s installed, you can use the which command on macOS and Linux. For example:

which python
Code language: Python (python)

This command will display the path to the Python interpreter if it’s installed.

If Python is not installed, you’ll typically see an error message indicating that the command is not recognized. In that case, you will need to download and install Python from the official Python website (https://www.python.org/downloads/).

Please note that the specific commands may vary slightly depending on your operating system and Python version, but the general approach remains the same.

How To Check What Version Of Python Is On Mac

To check what version of Python is installed on your Mac, you can use the Terminal. Here’s how:

  1. Open Terminal: You can find the Terminal application in your Applications folder or by using the Spotlight search.
  2. Type the Python Version Check Command: In the Terminal window, type the following command and press Enter:
python --versionCode language: Python (python)

Or, you can use python -V as an alternative:

python -VCode language: Python (python)

This command will display the installed Python version. For example, it might show something like “Python 3.8.5.”

  1. Check Python 2 (if installed): If you want to check if Python 2 is installed, you can use the python2 command:
python2 --versionCode language: Python (python)

Or:

python2 -VCode language: Python (python)

This will show the Python 2 version if it’s installed on your system.

Keep in mind that macOS usually includes a preinstalled Python 2.x version, yet it’s advisable to opt for Python 3 for most use cases, as Python 2 is now obsolete and no longer receives active maintenance. You can install Python 3 separately if it’s not already installed on your Mac.

How do I find out where Python is installed?


You can find out where Python is installed on your system by using the which command on macOS and Linux. Here’s how to do it:

  1. Open Terminal: Launch the Terminal application on your Mac or Linux system.
  2. Type the which Command: In the Terminal, type the following command and press Enter:
which pythonCode language: Python (python)

Executing this command will reveal the pathway to the Python interpreter presently utilized when you enter “python” in the Terminal.

If you want to find the location of a specific Python version, you can specify the version number, like this:

which python3.8  # Replace "3.8" with the desired version numberCode language: Python (python)

This will display the path to the Python 3.8 interpreter if it’s installed.

  1. Check Python 2 (if installed): Similarly, if you want to find the location of Python 2, you can use the which command with python2:
which python2Code language: Python (python)

This will show the path to the Python 2 interpreter if it’s installed on your system.

The which command will provide you with the full path to the Python executable that’s currently in your system’s PATH. This is the Python interpreter that will be executed when you run the python command in the Terminal.

Read More;

    by
  • Muhammad Nabil

    I am a skilled and experienced Python developer with a huge passion for programming and a keen eye for details. I earned a Bachelor's degree in Computer Engineering in 2019 from the Modern Academy for Engineering and Technology. I am passionate about helping programmers write better Python code, and I am confident that I can make a significant contribution to any team. I am also a creative thinker who can come up with new and innovative ways to improve the efficiency and readability of code. My specialization includes Python, Django, SQL, Apache NiFi, Apache Hadoop, AWS, and Linux (CentOS and Ubuntu). Besides my passion for Python, I am a solo traveler who loves Pink Floyd, online video games, and Italian pizza.

Leave a Comment