I recently tried to deploy a flask app using Heroku. However, I encountered an internal server error. My code can be found here: https://github.com/chaneth8/Task_List. This is the message that appeared on my log in Heroku – what could the error be?
2021-08-11T08:45:22.861047+00:00 app[web.1]: return fn(*args, **kwargs) 2021-08-11T08:45:22.861047+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/create.py", line 522, in create_engine 2021-08-11T08:45:22.861047+00:00 app[web.1]: entrypoint = u._get_entrypoint() 2021-08-11T08:45:22.861048+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/engine/url.py", line 636, in _get_entrypoint 2021-08-11T08:45:22.861048+00:00 app[web.1]: cls = registry.load(name) 2021-08-11T08:45:22.861048+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/sqlalchemy/util/langhelpers.py", line 343, in load 2021-08-11T08:45:22.861048+00:00 app[web.1]: raise exc.NoSuchModuleError( 2021-08-11T08:45:22.861049+00:00 app[web.1]: sqlalchemy.exc.NoSuchModuleError: Can't load plugin: sqlalchemy.dialects:postgres 2021-08-11T08:45:22.862035+00:00 app[web.1]: 10.1.24.101 - - [11/Aug/2021:08:45:22 +0000] "GET /main HTTP/1.1" 500 290 "https://evening-sands-15945.herokuapp.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36" 2021-08-11T08:45:22.862177+00:00 heroku[router]: at=info method=GET path="/main" host=evening-sands-15945.herokuapp.com request_id=4bc8206e-cdb1-4d4b-8cc4-05122855e894 fwd="58.177.96.125" dyno=web.1 connect=0ms service=17ms status=500 bytes=539 protocol=https
Thanks in advance.
Advertisement
Answer
I studied your code and hosted the same on https://ethan-flask.herokuapp.com/
The blunders you did:
from flask_session import Session
– remove this
Session(app)
– remove this
And add the following code at the end –
if __name__ == "main": app.run(port=8000)
I will create a PR on your repo soon Thanks ;)