简体   繁体   中英

Deploying Flask App to Heroku - ImportError Flask not found

I have some experience with Python Flask, but have only done local development. I am now messing around with Heroku to try and get some Flask projects on the web however I am having trouble even deploying a basic HelloWorld Flask application to Heroku. Right now my issue seems to be that it isn't processing the requirements right.

My Procfile looks like this:

web: python hello.py

and my hello.py file looks like this:

import os
from flask import Flask

app = Flask(__name__)

@app.route('/')
def hello():
    return 'Hello World!'

I have an updated version of requirements.txt generated from pip freeze > requirements.txt with Flask in it however when I type heroku ps in the toolbelt command line it crashes and gives me this in the log:

heroku[web.1]: Starting process with command 'python hello.py'
app[web.1]: ImportError: No module named flask
app[web.1]: Traceback (most recent call last):
app[web.1]: from flask import Flask
heroku[web.1]: State changed from starting to crashed

I cannot figure out how to get around this error that seems to be the thing stopping successful deployment, and when visiting the application site online, I obviously am met with the Application error saying my application cannot be served.

Any ideas as to why the processing of requirements may not be working correctly?

Thanks

Edit:

Add requirements.txt:

Flask==0.10.1
itsdangerous==0.24
Jinja2==2.7.3
MarkupSafe==0.23
Werkzeug==0.10.1

maybe remove the capitalization from Flask, to flask in the requirements.txt? but thats just whats always worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM