Charles Poli, PhD

Head of Artificial Intelligence,
Cambridge Quantum Computing Limited, London.

hon installation: a super short documentation


The Python installation is done using Xcode and MacPorts.

Get Xcode and Xcode command line tools

In a termminal,
  • xcode-select --install
and follow the instructions.

Get MacPorts

Go to and follow the instructions.
To upgrade, from time to time, the MacPorts:
  • sudo port selfupdate
  • port upgrade outdated

Get Python

The python version that will be installed is the 3.4.
If you want to install a version XX, just replace in the commands 34 by XX.
In a terminal:
  • sudo port install python35
  • sudo port install py35-setuptools py35-nose
  • # scientific librairies
  • sudo port install py35-numpy py35-scipy py35-matplotlib
  • # notebook
  • sudo port install py35-tornado py35-zmq # to use notebook parallel)
  • sudo port install py35-ipython +notebook +parallel py35-jupyter
  • # machine learning librairies
  • sudo port install py35-pandas py35-scikit-learn py35-seaborn
To use the command python
    sudo port select --set python python35
And it's done!

Check Python

In a terminal, launch python:
  • python
and copy paste the following Python commands.
To rapidly check the scientific modules:
  • import numpy as np
  • import scipy.sparse as sparse
  • import matplotlib.pyplot as plt
  • d0 = 9*np.ones(10)
  • d1 = np.arange(9)
  • m = sparse.diags([d1, d0, d1], [-1, 0, 1])
  • print(m.toarray())
  • a_min, a_max = -1.5, 1.5
  • a = np.linspace(a_min, a_max, 100)
  • x, y = np.meshgrid(a, a)
  • z = np.exp(-x*x-y*y)
  • fig, ax = plt.subplots()
  • ax.imshow(z, extent=[a_min, a_max, a_min, a_max])
To rapidly check the machine learning modules:
  • import pandas as pd
  • import matplotlib.pyplot as plt
  • import seaborn as sns
  • sns.set_style('whitegrid')
  • from import DataReader
  • from datetime import datetime

  • stocks = ['AAPL', 'NFLX', 'FB']
  • end =
  • start = datetime(end.year-1, end.month,
  • closing_df = DataReader(stocks, 'yahoo', start, end)['Adj Close']
  • closing_df.plot(legend=True, figsize=(10, 4), lw=3)
  • return_df = closing_df.pct_change()
  • sns.pairplot(return_df .dropna(), size=3)
  • plt.draw()

Other tools


  • sudo port install git
  • git config --global "Alex Dumas"
  • git config --global
One can then install packages from GitHub:
  • git clone
  • # I picked up a package to create animations in python notebooks
  • cd JSAnimation
  • python build
  • sudo python install

Text Editors / IDEs

Xcode (for mac users)
Note that Xcode is aleady installed.
  • touch # create an empty file
  • open # open the file with Xcode
Download and install Sublime.
To call Sublime from the Terminal:
  • sudo ln -s /Applications/Sublime\ /usr/bin
Then, to open a file using Sublime:
  • touch
  • subl
  • sudo port install emacs
  • sudo port install emacs-app
  • emacs # open the file in the terminal
To use your alt and meta keys as usual
Go to “Emacs” → “Preferences” → “Environment” → “Ns : GNUstep/Mac OS X specific features”
and change the following:
  “Ns Command Modifier” → “meta“
  “Ns Alternate Modifier” → “No modifier“

To change the background and mouse color
  open your “~/.emacs“
  paste the following code snippet:
  (setq default-frame-alist
  (append default-frame-alist
  '((foreground-color . "LawnGreen")
  (background-color . "Black")
  (cursor-color . "LawnGreen"))))

IPython notebook
  • ipython notebook


Just go to the Mac section and replace
  • sudo port
  • sudo get-apt


Just go to the Mac section and replace
  • sudo port
  • sudo yum


Get Python

Download and execute a Python version
Just go to the Mac section and replace
  • sudo port
  • pip
You can also download the unofficial Windows binaries from