SARose SARose - 2 months ago 17
Python Question

Deploying Flask App using Python 3.5 and Scipy on Heroku

I'm try to use create a flask web app on Heroku that uses python 3.5, scipy and flask.

It's well known I suppose that Heroku (still) can't install scipy on its platform. I'm wondering if anyone knows how to push a Flask app to Heroku that can use scipy. I know there are buildpacks that exist (like this one

https://github.com/kennethreitz/conda-buildpack
) but they don't use the version of python I would like and doesn't seem to let gunicorn and flask do there web app thing.

I don't know if that's clear enough so comment if there's anyway I can make it more clear.

Answer

EDIT I had to make a new buildpack that I will maintain since the one that I had previously was changed and now only supports Python 2.7. Mine supports Python 3.

Here's step by step what you should do.

1) Add this https://github.com/arose13/conda-buildpack.git to your BUILDPACK_URL

2) Create a conda-requirements.txt with all your requirements that you need anaconda to get, here is where you include python version 3 and scipy. This can be done in command-line with...

conda list -e > conda-requirements

3) Order matters in the conda-requirements.txt. It should look like this...

numpy=1.10.1
scipy=0.16.0

4) requirements.txt contains all the requirements that you want pip to install. You can use pip freeze > requirements.txt Just make sure that there's nothing on this list that is on the conda-requirements.txt list.

5) Push to Heroku.

PS: github project example is here https://github.com/arose13/HerokuCondaScipyFlaskApp