Guide: How to install python on Mac

Recently I’ve been enrolled myself into Udacity’s AI programming with Python. Before my class officially start, I want to get myself familiarized with Python’s programming syntax. I proceeded to download Python on my Mac to fiddle around with the REPL.

It’s important to note that OSX ships with Python 2 by default. However, since I’m picking up Python, I’ve proceeded to download the latest version of Python instead.

Before we get started on Python’s installation, we’ll need to have homebrew installed. If you do not have homebrew installed on your mac, you can follow the installation process here.

1. Installing Python

To get started, we will simply type the following in our terminal.

brew install python

2. Installing pip

pip is one of the more popular Python package managers out there. We’ll need pip in order to install virtualenv.

curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
python get-pip.py

3. Installing virtualenv

virtualenv is a tool to create isolated Python environments. With this, we can easily access different versions of Python for projects with different Python version. You can find out more about virtualenv and it’s documentation here.

pip install virtualenv

After the installation, we can easily access Python 3 using

python3

If you want to use python 2 instead, you can access it using ‘python2’.

And that’s all! Go and explore the world of Python!