How to Install Python 3 on Mac

Jun 13, 2018 - 20 Comments

Install Python 3 on Mac

Python is a popular programming language that is widely used by beginners and longtime developers alike. Modern Mac OS versions come with Python 2.7.x installed (or Python 2.6.1 if an older Mac OS X version), but many Python users may need to update Python in Mac OS to a newer version like Python 3.8.x or newer.

This article will discuss how to get an updated Python 3 installation on the Mac by covering two different ways to quickly and easily install Python 3 onto a Mac.


Note that we said install Python 3, not update to Python 3, because how this will work is installing Python 3 while simultaneously maintaining Python 2 on the Mac. This is essential because apparently some Mac apps rely on Python 2 support, so if you attempt to upgrade Python 2.x to Python 3.x in Mac OS you will eventually find that something is broken, perhaps critically so. With that in mind you should not attempt to update the existing preinstalled Python release on a Mac, instead you will just have a co-installation of Python 3 for full compatibility.

And yes, Python 3 and Python 2 can coexist on a Mac without any conflict, the usage commands will just be slightly different.

How to Install Python 3 in Mac OS

Perhaps the simplest way to install Python 3 is by using the Python package installer from python.org

  1. Go to Python.org downloads page here and download the latest Python installer package
  2. Run the Python installer package and install Python 3 onto the Mac
  3. Installing Python 3 on Mac OS

Python 3.8.x requires about 100mb of disk space to install. Installation is quick, and you’ll have Python 3.x alongside Python 2.x on the Mac.

Once Python 3 is installed you will find a Python3 folder within the /Applications directory of your Mac. You’ll also find the simple IDE called IDLE within the /Applications/MacPython3/ directory, which basically gives you the same Python IDE you’d encounter if you ran ‘python3’ at the command prompt in Terminal.

You can also install Python 3.x on a Mac through Homebrew, which is my preferred method as a Homebrew user.

How to Install Python 3.x with Homebrew

Installing an updated version of Python 3.8 (as of time of writing) is super easy with HomeBrew. Of course you will need Homebrew installed on the Mac before you can use the Homebrew method, but if you’re interested in messing around with Python then Homebrew will probably appeal to you anyway.

We’re going to assume you already have Homebrew, if you don’t the you can read here how to install Homebrew on Mac OS.

To install the latest version of Python 3 using Homebrew, just issue the following command string:

brew install python3

Once the updated Python 3 has been installed on the Mac, you can run it with:

python3

Whether you install the updated Python 3 with the package installer or Homebrew, the default version of Python 2.7 that comes preinstalled with Mac OS and Mac OS X will still be installed, completely untouched, and can be run with the simple “python” command as always.

How to Check What Version of Python is Currently Installed in Mac OS

From the Terminal application, simply typing the following command will report back what version of Python is currently installed:

python --version

In MacOS, you will find it’s typically Python 2.7.x of some variation, either 2.7.4 or 2.7.10 or similar.

After you have installed Python with Homebrew or with the package installer, you can check the updated new version of Python with:

python3 --version

And as mentioned before, both installations of Python will coexist without conflict.

Check python versions installed on Mac

You can also find out where each version of python is installed with the ‘which’ or ‘whereis’ command:

Which python installed where on Mac

Note that some aspects of Python are different in each version, and even features like the instant Python simple web server trick is different from version 2 to version 3. If you’re planning on using something longterm, or learning in general, you’ll be better off writing in Python 3.x rather than the older Python 2.x releases.

So now that you’ve got Python 3 installed, you’re ready to roll!

Learning Python, and Python Resources

If you’re new to Python and programming in general, there are a variety of great resources out there to get you started.

If you’re the type to enjoy learning from a book, some popular choices are the following (these are affiliate links to Amazon):

You can check out free online courses too, including these from MIT:

Or you can also explore the broad Python Wiki resources page here too.

TLDR: Don’t Update Python 2.x to Python 3.x, Just Install Python 3.x on the Mac

TLDR: Don’t update the preinstalled Python 2.x to Python 3.x, it will likely break something in doing so. Instead, just install and run the updated Python 3 separately.

.

Related articles:

Posted by: Paul Horowitz in Command Line, Mac OS, Tips & Tricks

20 Comments

» Comments RSS Feed

  1. Leonardo says:

    Hi,

    I installed python 3 on my M1 mac, via official website. Yet, when I ask terminal what python –version i have, it says 2.7.
    I even installed brew via terminal “successfully” to try and install python that way, but terminal keeps saying brew command does not exist.
    Could you help me?

    • Bharat says:

      I had the same problem. As the article mentions there are two parallel installations of python operating. So “python” is the older pre-installed version python. For your new installation try “python3 –version”

  2. DJ_17 says:

    Hello. I just installed Python 3 on Mac OS X. I get this error:

    WARNING: You are using pip version 20.2.3; however, version 20.2.4 is available.
    You should consider upgrading via the ‘/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install –upgrade pip’ command.

    How do I upgrade it?

    • Ace says:

      type /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -m pip install –upgrade pip into the terminal

  3. Hagen says:

    Great Post!
    One question: Do I need to tell other programs such as pycharm which python to use when i’ve both version installed? And if so, how do I do that? I assume, that programs should make use of the latest python version as a rule of thumb?!
    Thx!

  4. Rams says:

    Good work ! Keep it up :)

  5. Fareed Quraishi says:

    Thanks for writing this :thumbs-up:

  6. Cosmo says:

    `brew install python3` at this time, is only going to get you to 3.7.5
    https://formulae.brew.sh/formula/python#default

  7. Siya sharan Paliya says:

    While using pip to install libraries, system returns error as:
    ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/backports_abc.pyc’
    Consider using the `–user` option or check the permissions.

    even Python3.7.0 is installed on system.

  8. chmedly says:

    One caveat to using Homebrew is that, as of this post, it will only link to the Apple installed version of Tcl/Tk (tkinter). If you want Tk 8.6 (and everyone really should because there are various bugs and issues with the 8.5 versions) you can get it by installing with the Python.org installer. It’s not impossible to link the Homebrew install with a newly installed version of Tk but it’s very tricky and will likely cause you a headache – at least until they fix this issue.

    Otherwise, I like having a package manager on OSX and brew usually works pretty well.

  9. Gargo says:

    And? Installed as you say – 3.x over 2.x on OSX. Result – terminal shows that 2.x is installed

  10. TimA says:

    How do I delete my earlier python 3.5.1 so when I download 3.6x it will be the only active version?

  11. it worked for me. Thanks

  12. fyi says:

    Another free Learning Python book is available here:

    http://greenteapress.com/wp/think-python-2e/

    It is “Think Python 2nd Edition by Allen B. Downey” and available to download as PDF of view on the web

    Another is

    https://www.goodreads.com/book/show/8341335-learn-python-the-hard-way

    And some other free programming books are here:

    https://www.goodreads.com/list/show/91537.free_programming_books

    Enjoy!

  13. dd says:

    The Mu editor can be helpful for learning Python too:

    https://codewith.mu/

  14. Joe J says:

    Performed the brew install to 3.6.5 but when running python3 shows 3.6.2. “brew info python3” shows that brew knows about 3.6.5 but the command python3 will only load 3.6.2. Symlink that is not changing? How would I edit or change that?

  15. macpytho says:

    Fitting, I needed Python 3.6 for the Gif to ASCII CLI tool and it works great.

    https://github.com/google/gif-for-cli

    Cheers, thanks for helping upgrade to Python 3.6!

  16. Tomatos says:

    peenv is very useful tool. I recommend use it to switch between many python versions in system.

  17. Elwood Downey says:

    my brew seems to want to only upgrade:

    ecd-imac27: brew install python3
    Error: python 2.7.14_2 is already installed
    To upgrade to 3.6.5, run `brew upgrade python`

    • Paul says:

      Curious, what version of macOS?

      If you updated system software recently, may try:

      brew doctor

      And then try installing again.

      Also might be interesting to see specifics about what it thinks came from Homebrew:

      brew info python

      and

      brew info python3

Leave a Reply

 

Shop on Amazon.com and help support OSXDaily!

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates

Tips & Tricks

News

iPhone / iPad

Mac

Troubleshooting

Shop on Amazon to help support this site