How to install Python3 on 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. Homebrew has been recommended for its ease of use as well as its integration into the command line.”
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.
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
If it returns something different than command not found, it worked.
Now just try doctor
If you see something like “Your system is ready to brew.” you’re ready.
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.
All right, just go for it. Happy coding 🙂