Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku: sh: cython: not found

I'm trying to push my Python3 app to Heroku. It uses gevent which has a Cython dependency. When I try to push to Heroku, I get this error:

Running cython -o gevent.core.c gevent/core.pyx  # !EV_USE_SIGNALFD && !defined(LIBEV_EMBED) && !defined(_WIN32)

   sh: cython: not found

   Traceback (most recent call last):

     File "util/cythonpp.py", line 801, in <module>

       process_filename(filename, options.output_file)

     File "util/cythonpp.py", line 85, in process_filename

       output = run_cython(pyx_filename, sourcehash, output_filename, banner, comment)

     File "util/cythonpp.py", line 529, in run_cython

       system(command, comment)

     File "util/cythonpp.py", line 539, in system

       raise AssertionError('%r failed with code %s' % (command, result))

   AssertionError: 'cython -o gevent.core.c gevent/core.pyx' failed with code 32512

   make: *** [gevent/gevent.core.c] Error 1

   ----------------------------------------
   Command /app/.heroku/python/bin/python -c "import setuptools; __file__='/app/.heroku/src/gevent/setup.py'; exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" develop --no-deps failed with error code 1 in /app/.heroku/src/gevent
   Storing complete log in /app/.pip/pip.log

 !     Push rejected, failed to compile Python app

How can I fix this?

like image 515
zakdances Avatar asked Jun 05 '13 05:06

zakdances


People also ask

How do I run a Python script in Heroku?

Open the file using a text editor and add any dependencies needed such as numpy in order to run your project as when you deploy to Heroku the “pip” install command will be running to make sure all dependencies are present in order to run the script.

What is heroku Python?

Heroku makes it easy to deploy and scale Python apps. Whether you prefer frameworks like Django or Flask, or getting your hands dirty with Twisted or raw sockets, Heroku helps you build things your way with the tools you love.

How do I host an app on Heroku?

To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.


2 Answers

From the Heroku FAQ...

Can I require modules with C extensions?

Yes. If the module will install properly with pip. Most libraries that are required for web applications are available at build time.

However, sometimes a shared library needed for a module isn’t available. If this becomes a problem for you, you should contact [email protected] for help.

...so you'll probably have to e-mail them to get gevent and/or cython support.

like image 166
Aya Avatar answered Oct 01 '22 04:10

Aya


I needed to deploy to heroku a custom branch of gevent (with fixes to compatibility with CPython 2.7.9 for TLS client) that requires cython to build. My requirements.txt included, among other things:

Cython==0.22
-e git+https://github.com/zeevt/gevent.git@issue477#egg=gevent
grequests==0.2.0
gunicorn==19.3.0
requests==2.6.0

I got a sh: cython: not found trying to build gevent.

The way to deploy this to Heroku is by using two commits:

  1. First deploy an app that uses Cython but does not use a custom version of gevent. This will cause Cython to be installed.
  2. Then deploy the working version of the app that uses a custom branch of gevent. This will build fine because Cython is already installed.
like image 42
Z.T. Avatar answered Oct 01 '22 05:10

Z.T.