from __future__ import division
import os
import sys
import glob
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
%matplotlib inline
%precision 4'ggplot')

Julia and Python

You will need to install Julia from and make sure it is on your path. On Ubuntu you can install via apt-get with

sudo add-apt-repository ppa:staticfloat/juliareleases
sudo add-apt-repository ppa:staticfloat/julia-deps
sudo apt-get update
sudo apt-get install julia

Within an instance of Julia, run the following commands:


Then finally install pyjulia from

Make sure that you can start julia line - if not, add a symlink to it.

Installed To use it, type:
  %load_ext magic
%load_ext magic
%julia @pyimport matplotlib.pyplot as plt
%julia @pyimport numpy as np
%julia @pyimport numpy.random as npr
Initializing Julia interpreter. This may take some time...

Defining a function in Julia


function fib(n)
    a, b = 0.0,  1.0
    for i = 1:n
        a, b = a+b, a
    return a
<PyCall.jlwrap fib>

Using it in Python

jfib = %julia fib


Using Python libraries in Julia


xs = npr.multivariate_normal([0,0], np.eye(2), 100)
plt.scatter(xs[:,1], xs[:, 2], s=30);
<matplotlib.collections.PathCollection at 0x1220f3a50>


%timeit jfib(100)
10000 loops, best of 3: 22.9 µs per loop