Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Sep 9, 2012

🍰

@nguyenchiencong

This comment has been minimized.

Copy link

commented Nov 18, 2012

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

@badgley

This comment has been minimized.

Copy link

commented Nov 20, 2012

🍰

@Zyron

This comment has been minimized.

Copy link

commented Dec 2, 2012

🍰 :D

@Dsyko

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link

commented May 15, 2013

You are a god, thank you!

@AndreaCatalucci

This comment has been minimized.

Copy link

commented Nov 18, 2013

Thanks! Great solution, you saved my life!

@PerryGrossman

This comment has been minimized.

Copy link

commented Jan 29, 2016

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
You can’t perform that action at this time.