After digging through online resources, I am finally able to find two ways to calculate the Earth Mover’s distance writing in Python.

Interface between C implementation and Python modules

This approach is recommended for its speed. Basically, we add a file interface between the author’s C implementation and out own python modules.

  1. Update the author’s code to fulfil our requirements. Example: link
  2. Call through python modules. Example: link

Through Linear Programming Package (GLPK)

There are several steps to go.

  1. Install GLPK (could be done through brew)
  2. Install Pulp
  3. Run the following script

The result is:

160.542762808