Tuesday, July 16, 2024
Google search engine
HomeTutorialsPythonHow to Install Python 3 on macOS

How to Install Python 3 on macOS

Learn how to install Python 3.6.3 on macOS step-by-step. Python is a powerful, high-level programming language known for its readability and efficiency. Follow our guide to install Python 3 on your Mac and start coding with Python’s latest features today!

Introduction

Python is a high-level, dynamic, and versatile programming language known for its readability and efficiency. Initially developed by Guido Van Rossum in 1991, Python’s syntax emphasizes code readability, making it popular among developers worldwide. While macOS comes with Python 2.7 pre-installed, this tutorial will guide you through installing Python 3.6.3 on your macOS system.

Prerequisites

  • macOS operating system
  • Administrator privileges on the terminal

Installation Steps

1. Checking Python Version

First, check the currently installed Python version on your system. By default, macOS often includes Python 2.7.

Open your terminal and enter the following command:

bashCopy code$ python --version

This will display the installed Python version (e.g., Python 2.7.10).

2. Download Python 3.6.3

To install Python 3.6.3, download the latest version from the official Python website python.org/downloads. The downloaded file will be in .pkg format.

3. Install Python 3.6.3

Navigate to the directory where the downloaded .pkg file is located. Use the following command to install Python 3.6.3:

bashCopy code$ sudo installer -pkg python-3.6.3-macosx.pkg -target /

Replace python-3.6.3-macosx.pkg with the actual filename of your downloaded package.

You will be prompted to enter your administrator password. This command installs Python 3.6.3 into the root directory.

4. Verify Python 3 Installation

To verify the installation, check the Python 3 version using:

bashCopy code$ python3 --version

This command confirms the installed Python 3 version (e.g., Python 3.6.3).

5. Working with Python in Script Mode

To use Python interactively, open the terminal and type:

bashCopy code$ python3

This opens the Python shell where you can execute Python statements, such as print statements.

To run a Python script (saved as .py file), use:

bashCopy code$ python3 filename.py

Conclusion

Congratulations! You have successfully installed Python 3.6.3 on your macOS system. Now you can begin coding in Python 3 and leverage its powerful features.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments