How can I install numpy,scipy,matplotlib on Heroku?
So first locally I’m doing pip install matplotlib -> i get an error saying install numpy..
so i do pip install numpy and get an error saying
File "/home/sghose/myapp/helloflask/build/numpy/numpy/distutils/command/build_src.py", line 385, in generate_sources
source = func(extension, build_dir)
File "numpy/core/setup.py", line 410, in generate_config_h
moredefs, ignored = cocache.check_types(config_cmd, ext, build_dir)
File "numpy/core/setup.py", line 41, in check_types
out = check_types(*a, **kw)
File "numpy/core/setup.py", line 271, in check_types
"Cannot compile 'Python.h'. Perhaps you need to "\
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/sghose/myapp/helloflask/build/numpy
…what do I do now? Typically I would just do apt-get install python-numpy … but then I’m thinking pip won’t pick it up and then Heroku will be unhappy when I push… also I see a previous post where they recompiled numpy,scipy, matplotlib and changed vars so that they pointed to heroku packages (http://stackoverflow.com/questions/9819968/running-scipy-on-heroku) ? Is this still necessary? Sounds somewhat painful >_<
How Heroku installs dependencies
When you push code to Heroku, Heroku will only look at your
requirements.txtfile and install the packages that are listed in there.How you list those dependencies
Heroku doesn’t care about how you created that file (by hand, or using
pip freeze), so nothing prevents you from adding a package to therequirements.txtfile, you just have to add a line in there with the name of the requirement.How that solves your issue
Once you add the
matplotlibline to yourrequirements.txtfile, you can then push your code to Heroku, and they will figure out what to do with yourmatplotlibrequirement.If that doesn’t work, you can always contact Heroku, but if the only requirement is the python headers, I’d be surprised if it wasn’t available on Heroku.
Regarding local installation, Ben Mezger’s answer is right, you just have to:
apt-get installthe python headers (these are not a python package, so you don’t install them with pip). Heroku likely has those available already.