Cython error when pushing git on heroku master

2019-08-17 05:49发布

问题:

I am getting these errors when I hit the command, "git push heroku master". It tells me that I have to install Cython. I had also installed using "pip3 install cython" but it still shows me an error. I have also changed my requirements.txt file too.

回答1:

Another solution here you can try is bin/pre_compile script if you want to use requirements.txt.

To trace the buildpack bin/compile script (https://github.com/heroku/heroku-buildpack-python/blob/master/bin/compile#L183-L189), you can find the comments:

This part of the code is used to allow users to customize their build experience without forking the buildpack by providing a bin/pre_compile script, which gets run inline with the buildpack automatically.

Then in the script, you can add a line to install cython before executing pip install

$BUILD_DIR/.heroku/python/bin/python -m pip install cython

The $BUILD_DIR argument is the building environment of this build, all settings in this build will be saved here and deploy to production.

It works on my case, help it works for you too.

update

after heroku-18 stack, you need to use conda related mechanisms to install scientific packages. Here is the link: https://devcenter.heroku.com/articles/python-pip#scientific-python-users