How to install Python3 on macOS using Homebrew

Let’s see today how to easily use Phython 3 in your macOS using Homebrew.

Before starting let’s remember what’s Homebrew.

“Homebrew is a free and open-source software package management system that simplifies the installation of software on Apple’s macOS operating system. Originally written by Max Howell, the package manager has gained popularity in the Ruby on Rails community and earned praise for its extensibility.[1] Homebrew has been recommended for its ease of use[2] as well as its integration into the command line.[3]”

But particularly what I most like in Homebrew is the fact that by default it installs everything under /usr/local (can be changed) to avoid conflicts with system directories.

Installing Homebrew

To install it all you need is just a simple command in your terminal

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once it finishes just try it to see if it worked properly

brew

If it returns something different than command not found, it worked.

Now just try doctor

brew doctor

If you see something like “Your system is ready to brew.” you’re ready.

Python 3

Time to install Python 3 using Homebrew

brew install python3

Wait until the end of the installation and check if Python3 is there, executing python3 in your terminal, you must see something like that

Etna:playground-python adequeiroz$ python3
Python 3.6.1 (default, Mar 28 2017, 21:09:58)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>

Tip : Do not forget that the same pattern “3 in the end” applies for pip too, instead of executing pip you’ll use pip3.

Now is more of the same, write your code and use python3, if you’re using an IDE to it, do not forget to change your interpreter, if you’re using the default Homebrew configuration you’ll find it somewhere under /usr/local/Cellar, in my case.

/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/bin/python3

All right, just go for it. Happy coding 🙂

Allan de Queiroz

Allan de Queiroz
London based software engineer

XServer forward from Linux text mode for Headless purposes.

Hello, this post is about XServer forward from Linux text mode, **not ssh forward, anything related to VNC** or things like that.Recently...… Continue reading