alexaweb icon indicating copy to clipboard operation
alexaweb copied to clipboard

Create runtime.txt to set Python 2 in Heroku and avoid wsgiref error in build

Open mlsamuelson opened this issue 6 years ago • 1 comments

Following the instructions in the README.md, I was hitting the following error with the build when attempting to use Heroku:

Counting objects: 51, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (49/49), done.
  1 tornado==3.1.1
Writing objects: 100% (51/51), 19.59 KiB | 0 bytes/s, done.
Total 51 (delta 20), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote: -----> Installing python-3.6.4
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote:        Collecting tornado==3.1.1 (from -r /tmp/build_c641dabedf0c7b641806d046afee6e4b/requirements.txt (line 1))
remote:          Downloading tornado-3.1.1.tar.gz (374kB)
remote:        Collecting wsgiref==0.1.2 (from -r /tmp/build_c641dabedf0c7b641806d046afee6e4b/requirements.txt (line 2))
remote:          Downloading wsgiref-0.1.2.zip
remote:            Complete output from command python setup.py egg_info:
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-build-qeh7puxi/wsgiref/setup.py", line 5, in <module>
remote:                import ez_setup
remote:              File "/tmp/pip-build-qeh7puxi/wsgiref/ez_setup/__init__.py", line 170
remote:                print "Setuptools version",version,"or greater has been installed."
remote:                                         ^
remote:            SyntaxError: Missing parentheses in call to 'print'. Did you mean print(print "Setuptools version",version,"or greater has been installed.")?
remote:
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-qeh7puxi/wsgiref/
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !	Push rejected to notreallymyalexaweb.
remote:
To https://git.heroku.com/notreallymyalexaweb.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/notreallymyalexaweb.git'

Looks like wsgiref isn't supported in Python 3, which Heroku uses as the default per: https://devcenter.heroku.com/articles/python-runtimes

By including a runtime.txt file, you can set the Python version to python-2.7.14 and have a successful build.

mlsamuelson avatar Mar 05 '18 19:03 mlsamuelson

This is exactly what I came here to tell you!

vvlabs avatar Jun 24 '18 02:06 vvlabs