1.2: Installing Python on MAC#

As easy as it is to install Python on Windows, it is even easier to install it on Mac OS X. In fact, OS X comes with Python 2.7 already on the machine, though we will want to upgrade to Python 3.

Before installing Python, you’ll need to install GCC, which can best be obtained by downloading Xcode, available directly from Apple. Once Xcode and GCC are installed, we now need to install Homebrew, a convenient package manager for OS X. To install Homebrew, open Terminal and run:

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

Once you’ve installed Homebrew, insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file

$ export PATH="/usr/local/opt/python/libexec/bin:$PATH"

If you have OS X 10.12 (Sierra) or older use this line instead

$ export PATH=/usr/local/bin:/usr/local/sbin:$PATH

Now installing Python 3 is as easy as running the following in Terminal:

$ brew install python

To make sure it was installed correctly, run the following:

$ python --version

This should tell you which Python version you just installed. Easy!

Next type pip in the Command Prompt and immediately a good bit of information will pop up. Pip is the standard package manager for Python and allows users to install and manage additional packages that are not part of the Python standard library. On the command prompt you will see various commands and options that work with pip. Next, let’s make use of one of those commands and type pip install quantgov. After a few minutes, the QuantGov library (and all of the Python libraries that QuantGov uses) will be downloaded. This is the standard way to download any Python package/library. It is recommended that users also pip install pandas, pip install matplotlib, and pip install sklearn. Information for those three packages can be found in these locations: