Skip to content

Instantly share code, notes, and snippets.

@mt3
Forked from nicolashery/pandas-heroku.md
Created September 8, 2012 23:10
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mt3/3680810 to your computer and use it in GitHub Desktop.
Save mt3/3680810 to your computer and use it in GitHub Desktop.
Deploy Python app using Pandas on Heroku

Deploy Python app using Pandas on Heroku

2012-09-08

This document explains how to deploy a Python app that uses the Pandas library on Heroku.

Heroku builds Numpy (one of Pandas' requirements) fine. However, when trying to deploy an app with both numpy and pandas in its requirements.txt file (or even just pandas), for some reason it fails when trying to install Pandas with the following error:

Downloading/unpacking pandas==0.8.1 (from -r requirements.txt (line 3))
 Storing download in cache at /app/tmp/repo.git/.cache/pip_downloads/http%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2Fp%2Fpandas%2Fpandas-0.8.1.zip
 Running setup.py egg_info for package pandas
   # numpy needed to finish setup.  run:
   
       $ pip install numpy  # or easy_install numpy
   
   Complete output from command python setup.py egg_info:
   # numpy needed to finish setup.  run:



   $ pip install numpy  # or easy_install numpy



----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /app/.pip/pip.log

It looks like Pandas' install doesn't wait for Numpy to be built or something, but I'm not really sure.

The workaround is to first, deploy the app with only Numpy as a requirement. So requirements.txt looks like, in my example:

flask==0.8
numpy==1.6.2

Deploy:

$ heroku create appname
$ git add .
$ git commit -m "Add numpy as requirement"
$ git push heroku master

Numpy builds without any problems. Second, add Pandas as a requirement:

flask==0.8
numpy==1.6.2
pandas==0.8.1

Commit and update the app:

$ git add .
$ git commit -m "Add pandas as requirement"
$ git push heroku master

Numpy is already installed, Pandas should install correctly now.

Hope this helps!

@kennethreitz
Copy link

🍰

@nguyenchiencong
Copy link

🍰 🍰 🍰 🍰 🍰 You saved my day man! Thanks

@badgley
Copy link

badgley commented Nov 20, 2012

🍰

@Zyron
Copy link

Zyron commented Dec 2, 2012

🍰 :D

@Dsyko
Copy link

Dsyko commented May 5, 2013

Thought I was going to have to use this trick, but I just deployed a python app to Heroku using numpy and pandas and it all built just fine without this work-around. Thanks for sharing though, would have saved me a lot of time had this still been a problem =D

@acm46
Copy link

acm46 commented May 15, 2013

You are a god, thank you!

@AndreaCatalucci
Copy link

Thanks! Great solution, you saved my life!

@PerryGrossman
Copy link

Hi,
Thanks for this, but I'm not clear on the beginning steps for building a Pandas app on Heroku.

https://devcenter.heroku.com/articles/getting-started-with-python#introduction
does not work for me since I have some postgresql errors. So am hoping to just use Pandas.

Perry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment