1

I am working through the learning log project in Python Crash Course by Eric Matthes, specifically working on the learning log app. I am trying to deploy to heroku but get this error:

(ll_env) C:\Users\benpg\Documents\Coding\Python\learning_log>git push heroku master
Enumerating objects: 54, done.
Counting objects: 100% (54/54), done.
Delta compression using up to 4 threads
Compressing objects: 100% (46/46), done.
Writing objects: 100% (54/54), 16.54 KiB | 940.00 KiB/s, done.
Total 54 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.7.3
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.7.4
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to pacific-refuge-12657.
remote:
To https://git.heroku.com/pacific-refuge-12657.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/pacific-refuge-12657.git'

Tried everything here including the two other questions linked at the start, no luck.

Here's my requirements.txt:

Django==1.8.4
dj-database-url==0.3.0
dj-static==0.0.6
django-bootstrap3==6.2.2
gunicorn==19.3.0
static3==0.6.1
psycopg2>=2.6.1

Edit: I am using django 2.2.4. My requirements.txt is the way it is because there is a note in the book saying 'if you're using Windows, make sure your version of requirements.txt matches the list shown here regardless of which packages you were able to install'. Why is this?

This is the first requirements.txt I had, autogenerated except for the last line. This one didn't work either, same error message:

dj-database-url==0.5.0
dj-static==0.0.6
Django==2.2.4
django-bootstrap3==11.1.0
gunicorn==19.9.0
pytz==2019.2
sqlparse==0.3.0
static3==0.7.0
psycopg2>=2.6.1
  • Do you have your `requirements.txt` at project root at the same level of `manage.py`? Also check the spelling. – MD. Khairul Basar Aug 19 '19 at 16:10
  • 1
    Django 1.8.4 is years out of date, doesn't receive security updates. There is a mismatch between Django 1.8 which supports up to Python 3.5, and Heroku [which supports](https://devcenter.heroku.com/articles/python-support#supported-runtimes) Python 3.6 and 3.7 (both support Python 2 but you should avoid Python 2 for new projects. – Alasdair Aug 19 '19 at 16:11
  • Also update Django te latest version. Or at least `1.11.x`. – MD. Khairul Basar Aug 19 '19 at 16:14
  • 1
    I would avoid following a tutorial written for Django 1.8. Lots has changed since then so you'll hit problems like this. I'm not familiar with the python-crash-course book, so I don't know whether there's a newer version that uses a more up to date version of Django. The [pcc repo](https://github.com/ehmatthes/pcc/tree/6bfeca0cc6a01106bd8e67f707db4e7a85fbd3f8/chapter_20/learning_log_django_2.0) appears to have a copy of the project updated for Django 2.0 which might help you. – Alasdair Aug 19 '19 at 16:19
  • @MD. Khairul Basar requirements is in the right directory, spelling checked – Ben Gutteridge Aug 19 '19 at 16:20
  • Agree with the above, you can learn a good deal of concepts following a Django 1.8 tutorial, but you have to bare in mind that you shouldn't deploy a Django 1.8 app (you'd want to start a new project with 2.2) and that some things will have changed. So if you want to learn to deploy, migrate your app to 2.2 and deploy from there. – dirkgroten Aug 19 '19 at 16:21
  • @Alasdair updated question - essentially I am running django 2.2.4, it's just the requirements file that says I'm not, and when I use the default I get the same error – Ben Gutteridge Aug 20 '19 at 09:11
  • It's important to have the correct version in the requirements, otherwise Heroku will install the wrong version when you deploy your app. There don't seem to be any error messages that relate to your app. If you search for recent results for *Push rejected, failed to compile Python app*, [this question](https://stackoverflow.com/q/56677029/113962) suggests it's a Heroku issue, and changing the stack might work. – Alasdair Aug 20 '19 at 09:21

1 Answers1

1

Just had the same issue, changing the Python version back do 3.7.3 fixed it. Was able to build python and execute.

guestusre
  • 11
  • 1