Brad Lucas

Programming, Clojure and other interests
July 20, 2017

Python 3

Installing

On a Mac here is an easy method to get Python 3 installed.

$ brew install python3

After this step you'll have your original Python 2.7 version as python and your new Python 3 version as python3.

Virtual Environments

I've been in the habit of creating a virtual environment in a directory called env under each project I'm working on. With 2.7 I was using virtualenv. With Python 3 installed this would be a conflict. Nicely, Python3 has it's own method for creating virtual environments through python itself. Simply pass -m venv followed by the name of the virtual environment and you are good to go.

$ python3 -m venv env

Even more nice is the results where after activating your environment you'll find that the mappings for pip3 and python3 are pip and python.

$ source env/bin/activate
(env) $ pip --version
pip 9.0.1 from /Users/brad/tmp/env/lib/python3.6/site-packages (python 3.6)
(env) $ python --version
Python 3.6.1
Tags: python