Mark
Mark

Reputation: 73

Why do I have errors deploying to heroku?

I am trying to push my app to heroku, I am following the tutorial from udemy - everything goes smooth as explained. Once I am at the last step - doing git push heroku master I get the following error in the console:

(flaskdeploy) C:\Users\dmitr\Desktop\jose\FLASK_heroku>git push heroku master
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to mitya-test-app.
remote:
To https://git.heroku.com/mitya-test-app.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/mitya-test-app.git'

On a heroku site in the log area I have the following explanation of this error:

-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Python app detected
-----> Installing python-3.6.13
-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting certifi==2020.12.5
         Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
       Processing /home/linux1/recipes/ci/click_1610990599742/work
       ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/linux1/recipes/ci/click_1610990599742/work'
       
 !     Push rejected, failed to compile Python app.
 !     Push failed

In my requirements.txt I have the following:

certifi==2020.12.5
click @ file:///home/linux1/recipes/ci/click_1610990599742/work
Flask @ file:///home/ktietz/src/ci/flask_1611932660458/work
gunicorn==20.0.4
itsdangerous @ file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 @ file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe @ file:///C:/ci/markupsafe_1607027406824/work
Werkzeug @ file:///home/ktietz/src/ci/werkzeug_1611932622770/work
wincertstore==0.2

This is, in fact, only a super simple test app that consists of app.py:

from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "THE SITE IS OK"    

if __name__ == '__main__':
    app.run()

and Procfile with this inside:

web: gunicorn app:app

Upvotes: 0

Views: 755

Answers (2)

dswij
dswij

Reputation: 148

I see a windows path in your requirements.txt. Not sure what you are trying to do there, but is there any reason that you install the packages from a local source?

So, I believe looking at the log from

ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/linux1/recipes/ci/click_1610990599742/work

means that pip tries to install from a directory that does not exist. Your heroku dyno (container) tries to get the necessary dependency but failed when building. If you are not familiar with container, in essence it's an isolated barebone system that will build from the ground up, so it needs to install them (click, flask, etc.)

tl;dr heroku wants install from local, failed. Try changing requirements.txt e.g.

certifi==2020.12.5
click
Flask
gunicorn==20.0.4
itsdangerous
Jinja2
MarkupSafe
Werkzeug
wincertstore==0.2

to force pip to install from outside source (i.e. pypi).

Upvotes: 1

Hiroaki Genpati
Hiroaki Genpati

Reputation: 79

i think the problem is in requirement.txt

remove

click @ file:///home/linux1/recipes/ci/click_1610990599742/work
Flask @ file:///home/ktietz/src/ci/flask_1611932660458/work
itsdangerous @ file:///home/ktietz/src/ci/itsdangerous_1611932585308/work
Jinja2 @ file:///tmp/build/80754af9/jinja2_1612213139570/work
MarkupSafe @ file:///C:/ci/markupsafe_1607027406824/work
Werkzeug @ file:///home/ktietz/src/ci/werkzeug_1611932622770/work

and replace with

Flask==1.1.2

because the packages is not find by heroku. heroku will pull packages from requiremts.txt from pypi

Upvotes: 1

Related Questions