How to install scikit-learn on heroku cedar?

前端 未结 5 1925
孤城傲影
孤城傲影 2021-01-13 00:23

I\'v successfully installed numpy and scipy using the method described in this answer. Then I wanted to add scikit-learn so at first I tried adding scikit-learn==0.11<

5条回答
  •  粉色の甜心
    2021-01-13 00:41

    Another good option is the conda buildpack, which allows you to add any of the free Linux64 packages available through Anaconda/Miniconda to a Heroku app. Some of the most popular packages include numpy, scipy, scikit-learn, statsmodels, and pandas. While the buildpack makes it fairly simple to add packages to an app, the downsides are that the buildback takes up a lot of space and that you have to wait on Anaconda to update the libraries in the repository.

    If you are starting a new Python app on Heroku, you can add the conda buildpack using the command:

    $ heroku create YOUR_APP_NAME --buildpack https://github.com/kennethreitz/conda-buildpack.git
    

    If you have already setup a Python app on Heroku, you can add the conda buildpack to the existing app using the command:

    $ heroku config:add BUILDPACK_URL=https://github.com/kennethreitz/conda-buildpack.git
    

    Or, if you need to specify the app by name:

    $ heroku config:add BUILDPACK_URL=https://github.com/kennethreitz/conda-buildpack.git --app YOUR_APP_NAME
    

    To use the buildpack, you will need to include two text files in the app directory, requirements.txt and conda-requirements.txt. Just as with the standard Python buildpack, the requirements.txt file lists packages that should be installed using pip. Packages that should be installed using conda are listed in the conda-requirements.txt file. Some of the most useful scientific packages include numpy, scipy, scikit-learn, statsmodels, pandas, and cvxopt. The full list of available conda packages can be found at repo.continuum.io.

    For example:

    $ cat requirements.txt
    gunicorn==0.14.2
    requests==0.11.1
    
    $ cat conda-requirements.txt
    scipy
    numpy
    cvxopt
    

    That’s it! You can now add Anaconda packages to a Python app on Heroku.

提交回复
热议问题