• Home
  • Troubleshoot
  • #Example
    • C
    • C++
    • Python
    • R-Programming
  • DSA
  • Quiz
  • Tutorial Videos
  • Home
  • Troubleshoot
  • #Example
    • C
    • C++
    • Python
    • R-Programming
  • DSA
  • Quiz
  • Tutorial Videos
  • #Deals
  • #News
  • #WiKi
  • #APPS
  • #Events
    • #WWDC
    • #I/O
    • #Ignite
  • #Let’s Talk

MyCodeTips mycodetips-newlogocopy1

  • Home
  • Troubleshoot
  • #Example
    • C
    • C++
    • Python
    • R-Programming
  • DSA
  • Quiz
  • Tutorial Videos
Programming

How to Install python on Mac

How to Install python on Mac

How to Install python on Mac

The best way we found to install Python 3 on macOS is through the Homebrew package manager.

There are following steps which are used while installing Python3 on MacOS.

Prerequisites

  1. MacOS
  2. Login as an administrator on terminal

Installation

1) Checking python’s version on the system

We can check which version of the Python is currently installed on our system. Generally, Python 2.7 is installed by default.

Let’s see how can we do it.

$ python -version

Macos Python 1
It shows Python 2.7.10 is installed on the computer which is quite often.

2) Download Python 3.6.3

In order to install Python 3.6.3, we must download the latest version from its official website https://www.python.org/downloads/ . The file is downloaded in .pkg format which can be directly installed by using Installer command.

3) Install Python 3.6.3

Since the downloaded file already is in .pkg format hence no mounting is required and We can use installer command to install Python 3.6.3.

Also Read : How to install python on windows

Let’s see how can we do it.

Macos Python 2
Since The installer is used with super user permissions hence sudo forces terminal to prompt the user to fill the admin password. The process installs the Python 3.6.3 to the root directory which is mentioned with the target option.

4) Verify Python3

To check which Python version is installed on the machine, we can use python -version command. Since by default installed version is Python 2.7.10 hence it shows python 2.7.10. but it gives us flexibility to check the version of Python 3 on our computer.

Let’s see how can we use python 3 to check which version of python 3 is running.

$ python -version

5) Working on Python’s script mode

To work on Python command line, we simply type python3 on the terminal. Python shell open where we can run Python statements such as print statements as we did here.

Macos Python 3
To run a Python file (.py) on the terminal, we simply type the file name and the file will be interpreted.

Well, we have installed Python3 on our MacOS.

The best way we found to install Python 3 on macOS is through the Homebrew package manager.

Step 1: Install Homebrew (Part 1)
To get started, you first want to install Homebrew:

Open a browser and navigate to http://brew.sh/. After the page has finished loading, select the Homebrew bootstrap code under “Install Homebrew”. Then hit Cmd+C to copy it to the clipboard. Make sure you’ve captured the text of the complete command because otherwise the installation will fail.

Now you need to open a Terminal.app window, paste the Homebrew bootstrap code, and then hit Enter. This will begin the Homebrew installation.

If you’re doing this on a fresh install of macOS, you may get a pop up alert asking you to install Apple’s “command line developer tools”. You’ll need those to continue with the installation, so please confirm the dialog box by clicking on “Install”.
At this point, you’re likely waiting for the command line developer tools to finish installing, and that’s going to take a few minutes. Time to grab a coffee or tea!

Step 2: Install Homebrew (Part 2)
You can continue installing Homebrew and then Python after the command line developer tools installation is complete:

Confirm the “The software was installed” dialog from the developer tools installer.
Back in the terminal, hit Enter to continue with the Homebrew installation.

Homebrew asks you to enter your password so it can finalize the installation. Enter your user account password and hit Enter to continue.
Depending on your internet connection, Homebrew will take a few minutes to download its required files. Once the installation is complete, you’ll end up back at the command prompt in your terminal window.

Whew! Now that the Homebrew package manager is set up, let’s continue on with installing Python 3 on your system.

Step 3: Install Python
Once Homebrew has finished installing, return to your terminal and run the following command:

$ brew install python3

Note: When you copy this command, be sure you don’t include the $ character at the beginning. That’s just an indicator that this is a console command.

This will download and install the latest version of Python. After the Homebrew brew install command finishes, Python 3 should be installed on your system.

You can make sure everything went correctly by testing if Python can be accessed from the terminal:

Open the terminal by launching Terminal.app.
Type pip3 and hit Enter.

You should see the help text from Python’s “Pip” package manager. If you get an error message running pip3, go through the Python install steps again to make sure you have a working Python installation.
Assuming everything went well and you saw the output from Pip in your command prompt window…congratulations! You just installed Python on your system, and you’re all set to continue with the next section in this tutorial.

  • Click to share on Reddit (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to share on Pocket (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
Written by Ranjan - 1275 Views
AUTHOR
Ranjan

I m Ranjan and Sharing my years of experience in Software Development. Love to code in Mobile apps (IOS, Android, Power Apps, Xamarin, Flutter), Machine Learning ( Beginner ), Dot Net, Databases ( SQL Server, MySql, SQLite), WordPress, Cloud Computing ( AWS, Azure, Google, MongoDB) and many more as required on project-specific. Besides this love to travel and cook.

Next Post
Previous Post

Subscribe for updates

Join 5,733 other subscribers

whiteboard

Whiteboard(PRO)

whiteboard

Whiteboard(lite)

alphabets

Kids Alphabet

techlynk

Techlynk

techbyte

Do2Day

techbyte

Techbyte

Latest Posts

  • Frameworks of IOS
    Frameworks of IOS – Part ( I )
  • NSFileManager or NSPathUtilities
    NSFileManager or NSPathUtilities in Objective-C
  • Passing data between view controllers in Objective-C
    Passing data between view controllers in Objective-C
  • structures-classes-enum
    Structures and Classes in swift !
  • control-system-swift
    Control Flow in Swift
  • swift-concurrency-await
    Concurrency in Swift
  • time-complexity-dsa
    The Term Time Complexity in DSA
  • objective-c-datatypes1
    Objective-C Data Types
  • Convert-jpeg-word
    Convert JPG to Word – Tips You Should Try!
  • objective-c-control-statements2
    Objective-C control statements and loops !

Quick Links

  • #about
  • #myapps
  • #contact
  • #privacy

Other Websites

  • #myQuestions
  • #myBhojanalaya
  • #gadgetFacts
  • #ifscCodesDB

Tag Cloud

Android Android Studio API APP Programming Apps ARC asp.net blogging Browser Config CSS DATABASE DFD error Features GUI HTML HTML5 IDE IIS installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode

©mycodetips.com