Flask app on heroku - heroku

I have an issue making my flask app working on heroku.
I'm using a simple flask app along flask-sqlalchemy
I didin't find anything specific on my problem altough I think I understand but can't figure it out how to make it work.
Here is the requirements.txt content:
alembic==0.9.2
click==6.7
Flask==0.12.2
Flask-Migrate==2.0.4
Flask-Script==2.0.5
Flask-SQLAlchemy==2.2
Flask-WTF==0.14.2
gunicorn==19.7.1
itsdangerous==0.24
Jinja2==2.9.6
Mako==1.0.6
MarkupSafe==1.0
python-dateutil==2.6.0
python-editor==1.0.3
six==1.10.0
SQLAlchemy==1.1.10
Werkzeug==0.12.2
WTForms==2.1
Here is the Procfile content:
web: gunicorn main:app
Here is the output of log files in heroku dashboard
2017-06-03T06:59:24.005560+00:00 app[web.1]: return __import__('MySQLdb')
2017-06-03T06:59:24.005561+00:00 app[web.1]: ImportError: No module named MySQLdb
2017-06-03T06:59:24.769740+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=aqueous-spire-85572.herokuapp.com request_id=965e64b9-20f0-4aa0-8a71-d564068a5c70 fwd="31.5.203.202" dyno=web.1 connect=1ms service=16ms status=404 bytes=386 protocol=https
2017-06-03T07:32:46.321187+00:00 heroku[web.1]: Idling
2017-06-03T07:32:46.321726+00:00 heroku[web.1]: State changed from up to down
2017-06-03T07:32:47.062599+00:00 app[web.1]: [2017-06-03 07:32:47 +0000] [4] [INFO] Handling signal: term
2017-06-03T07:32:47.062699+00:00 app[web.1]: [2017-06-03 07:32:47 +0000] [10] [INFO] Worker exiting (pid: 10)
2017-06-03T07:32:47.063539+00:00 app[web.1]: [2017-06-03 07:32:47 +0000] [9] [INFO] Worker exiting (pid: 9)
2017-06-03T07:32:47.110825+00:00 app[web.1]: [2017-06-03 07:32:47 +0000] [4] [INFO] Shutting down: Master
2017-06-03T07:32:47.055557+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2017-06-03T07:32:47.247466+00:00 heroku[web.1]: Process exited with status 0

The error message tells you, that you haven't installed the MySQLdb module. Add it to your requirements.txt

Related

How can make the requests_futures module not create an error with Heroku? [duplicate]

This question already has answers here:
Heroku: ModuleNotFoundError :No module named 'requests'
(1 answer)
gunicorn command not found, but it's in my requirements.txt
(1 answer)
Closed 3 months ago.
When I try deploying my Flask app to Heroku, I get a ModuleNotFound Error for requests_futures.
I have included it in requirements.txt and I am still getting the issue. Heroku deploys fine without the requests_futures module. Is there anything I can do?
2022-11-07T22:26:40.279231+00:00 app[web.1]: from app.main import app
2022-11-07T22:26:40.279231+00:00 app[web.1]: File "/app/app/main.py", line 3, in <module>
2022-11-07T22:26:40.279231+00:00 app[web.1]: from .tools.web_scraping import web_scrape
2022-11-07T22:26:40.279231+00:00 app[web.1]: File "/app/app/tools/web_scraping/web_scrape.py", line 4, in <module>
2022-11-07T22:26:40.279232+00:00 app[web.1]: from requests_futures import sessions
2022-11-07T22:26:40.279232+00:00 app[web.1]: ModuleNotFoundError: No module named 'requests_futures'
2022-11-07T22:26:40.279381+00:00 app[web.1]: [2022-11-07 22:26:40 +0000] [9] [INFO] Worker exiting (pid: 9)
2022-11-07T22:27:10.906569+00:00 app[web.1]: [2022-11-07 22:27:10 +0000] [4] [INFO] Shutting down: Master
2022-11-07T22:27:10.906610+00:00 app[web.1]: [2022-11-07 22:27:10 +0000] [4] [INFO] Reason: Worker failed to boot.
2022-11-07T22:27:11.054365+00:00 heroku[web.1]: Process exited with status 3
2022-11-07T22:27:11.153534+00:00 heroku[web.1]: State changed from up to crashed
2022-11-07T22:27:11.963376+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shows-4-u.herokuapp.com request_id=e0cd543f-98cc-486f-a27e-8f07b97c720f fwd="148.101.185.226" dyno=web.1 connect=0ms service= status=503 bytes= protocol=https
2022-11-07T22:57:34.354131+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=shows-4-u.herokuapp.com request_id=937c2b54-5df2-4e42-b056-1582c6137e0c fwd="148.101.185.226" dyno= connect= service= status=503 bytes= protocol=https
This is my requirements.txt
appdirs==1.4.4
beautifulsoup4==4.11.1
bs4==0.0.1
certifi==2022.9.24
charset-normalizer==2.1.1
click==8.1.3
cssselect==1.2.0
fake-useragent==0.1.14
Flask==2.2.2
gunicorn==20.1.0
idna==3.4
importlib-metadata==5.0.0
itsdangerous==2.1.2
Jinja2==3.1.2
lxml==4.9.1
MarkupSafe==2.1.1
parse==1.19.0
pyee==8.2.2
pyppeteer==1.0.2
pyquery==1.4.3
requests==2.28.1
requests-futures==1.0.0
requests-html==0.10.0
soupsieve==2.3.2.post1
tqdm==4.64.1
urllib3==1.26.12
w3lib==2.0.1
websockets==10.4
Werkzeug==2.2.2
zipp==3.10.0
This is the build log
-----> Using buildpack: heroku/python
-----> Python app detected
-----> Using Python version specified in runtime.txt
!
! A Python security update is available! Upgrade as soon as possible to: python-3.10.8
! See: https://devcenter.heroku.com/articles/python-runtimes
!
-----> Requirements file has been changed, clearing cached dependencies
-----> Installing python-3.10.7
-----> Installing pip 22.3.1, setuptools 63.4.3 and wheel 0.37.1
-----> Installing dependencies with Pipenv 2020.11.15
Installing dependencies from Pipfile.lock (3a221c)...
Collecting beautifulsoup4==4.9.3
Downloading beautifulsoup4-4.9.3-py3-none-any.whl (115 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 115.8/115.8 kB 443.5 kB/s eta 0:00:00
Installing collected packages: beautifulsoup4
WARNING: Ignoring invalid distribution -ertifi (/tmp/build_1fedda59/.heroku/python/lib/python3.10/site-packages)
Successfully installed beautifulsoup4-4.9.3
Ignoring importlib-metadata: markers 'python_version < "3.10"' don't match your environment
-----> Installing SQLite3
-----> Discovering process types
Procfile declares types -> web
-----> Compressing...
Done: 48.2M
-----> Launching...
Released v21
https://shows-4-u.herokuapp.com/ deployed to Heroku
Starting November 28th, 2022, free Heroku Dynos, free Heroku Postgres, and free Heroku Data for Redis® will no longer be available.
If you have apps using any of these resources, you must upgrade to paid plans by this date to ensure your apps continue to run and to retain your data. For students, we will announce a new program by the end of September. Learn more at https://blog.heroku.com/next-chapter```

Heroku App crashes error H10 but build succeeds [duplicate]

This question already has answers here:
error cannot import name 'cached_property' from 'werkzeug' when importing [ `from werkzeug.utils import cached_property` ]
(1 answer)
Python3 'Cannot import name 'cached_property'
(6 answers)
Closed 4 months ago.
Hi been looking for a solution for this for hours, need a fresh set of eyes. When deploying my app to heroku the logs have it crashing showing that a worker failed to boot and an import error shortly before that.
Now the current import error is from werkzueg but before I updated flask I was getting an import error from Jninja for 'escape'.
I've also seen that an improper procfile may cause this but I'm pretty sure my procfile is correct.
I'm not setting any ports in either my front/backend and have set the endpoint on the frontend to the url heroku gives me for the build with my specified endpoint.
tldr I don't know what is causing this error
Link to the github for more detailed code https://github.com/Jmumford45/Heart_Prediction_ML
directory outline
app.py is inside Backend
Procfile: web: gunicorn --chdir Backend app:app
error msg:
2022-10-28T23:58:23.563836+00:00 app[web.1]: from werkzeug import cached_property
2022-10-28T23:58:23.563836+00:00 app[web.1]: ImportError: cannot import name 'cached_property' from 'werkzeug' (/app/.heroku/python/lib/python3.10/site-packages/werkzeug/__init__.py)
2022-10-28T23:58:23.563946+00:00 app[web.1]: [2022-10-28 23:58:23 +0000] [9] [INFO] Worker exiting (pid: 9)
2022-10-28T23:58:24.168158+00:00 heroku[web.1]: Process exited with status 3
2022-10-28T23:58:24.234294+00:00 heroku[web.1]: State changed from up to crashed
2022-10-28T23:58:23.897642+00:00 app[web.1]: [2022-10-28 23:58:23 +0000] [4] [WARNING] Worker with pid 9 was terminated due to signal 15
2022-10-28T23:58:23.995629+00:00 app[web.1]: [2022-10-28 23:58:23 +0000] [4] [INFO] Shutting down: Master
2022-10-28T23:58:23.995660+00:00 app[web.1]: [2022-10-28 23:58:23 +0000] [4] [INFO] Reason: Worker failed to boot.
2022-10-28T23:58:47.000000+00:00 app[api]: Build succeeded
2022-10-28T23:58:54.059490+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=heartprediction-app.herokuapp.com request_id=ef722647-4325-4aae-8385-b0ba969c3aa7 fwd="72.111.98.148" dyno= connect= service= status=503 bytes= protocol=https
2022-10-28T23:58:53.791791+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=heartprediction-app.herokuapp.com request_id=fde1ae30-50f0-46d3-b27c-6cd2494ad4d5 fwd="72.111.98.148" dyno= connect= service= status=503 bytes= protocol=https

Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch when building a streamlit web app on Heroku

I was building a web application on Heroku and encountered this issue:
2020-10-24T03:56:57.857273+00:00 app[web.1]: You can now view your Streamlit app in your browser.
2020-10-24T03:56:57.857320+00:00 app[web.1]:
2020-10-24T03:56:57.857675+00:00 app[web.1]: Network URL: http://172.17.131.6:8501
2020-10-24T03:56:57.857819+00:00 app[web.1]: External URL: http://34.202.9.122:8501
2020-10-24T03:56:57.857932+00:00 app[web.1]:
2020-10-24T03:56:59.458188+00:00 app[web.1]: 2020-10-24 03:56:59.458 Generating new fontManager, this may take some time...
2020-10-24T03:57:41.000000+00:00 app[api]: Build succeeded
2020-10-24T03:57:52.127634+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2020-10-24T03:57:52.147741+00:00 heroku[web.1]: Stopping process with SIGKILL
2020-10-24T03:57:52.252583+00:00 heroku[web.1]: Process exited with status 137
2020-10-24T03:57:52.301275+00:00 heroku[web.1]: State changed from starting to crashed
2020-10-24T03:57:53.705631+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=okc-thunder-rebounds.herokuapp.com request_id=a90bb347-f583-4bec-8a6c-37bfea93908e fwd="71.232.30.113" dyno= connect= service= status=503 bytes= protocol=https
My setup.sh is like:
mkdir -p ~/.streamlit/
echo "\
[general]\n\
email = \"qemail#domain.com\"\n\
" > ~/.streamlit/credentials.toml
echo "\
[server]\n\
headless = true\n\
enableCORS=false\n\
port = $PORT\n\
" > ~/.streamlit/config.toml
And my Procfile is like:
web: sh setup.sh && streamlit run rebound_app.py
Where does it go wrong?
The application must bind to the port provided by Heroku via the $PORT env variable. This is a requirement for every Web Dyno.
You need to pass the $PORT to streamlit
echo PORT $PORT
streamlit run --server.port $PORT rebound_app.py

We're sorry, but something went wrong Heroku

Don't start app at Heroku.
Migrate I was do, but it don`t work anyway... Please help my anyone
2015-07-17T08:27:11.996879+00:00 app[web.1]: => Booting Puma
2015-07-17T08:27:11.996906+00:00 app[web.1]: => Rails 4.2.1 application starting in production on http://0.0.0.0:15906
2015-07-17T08:27:11.996909+00:00 app[web.1]: => Run `rails server -h for more startup options
2015-07-17T08:27:11.996910+00:00 app[web.1]: => Ctrl-C to shutdown server
2015-07-17T08:27:16.038259+00:00 heroku[web.1]: State changed from starting to up
2015-07-17T08:27:15.924000+00:00 app[web.1]: Puma 2.11.3 starting...
2015-07-17T08:27:15.924095+00:00 app[web.1]: * Min threads: 0, max threads: 16
2015-07-17T08:27:15.924199+00:00 app[web.1]: * Environment: production
2015-07-17T08:27:15.924281+00:00 app[web.1]: * Listening on tcp://0.0.0.0:15906
2015-07-17T08:27:18.702571+00:00 heroku[router]: at=info method=GET path="/" host=shrouded-eyrie-5960.herokuapp.com request_id=7976700d-bee7-4e6f-b20a-67d60a5d5e8a fwd="176.104.8.251" dyno=web.1 connect=1ms service=210ms status=500 bytes=1669
2015-07-17T08:27:18.819798+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=shrouded-eyrie-5960.herokuapp.com request_id=23341143-bd39-46ed-a48a-736533558ccd fwd="176.104.8.251" dyno=web.1 connect=1ms service=2ms status=200 bytes=143`
This error comes from your app's code. However, your app is sending it's logs to the local filesystem, which means you don't see the exception in heroku logs.
You would need to configure your app to send logs to STDOUT or STDERR to be able to see them.
You can add the rails_12factor gem to your app, which will change your configuration to do just that.
Once you have added this gem to your app and redeployed it, the raised exception should show in your logs and you can fix in your app's code.

Clojure (Joodo) deployment on Heroku failing

I'm having some trouble getting my Joodo application to deploy to Heroku. According to the deployment instructions here http://joodoweb.com/, we can theoretically deploy without specifying a Procfile. This causes Heroku to run lein with-profile production trampoline run as the default command to launch the project. This leads to this error:
2014-04-26T19:30:46.899454+00:00 app[web.1]: Error encountered performing task 'trampoline' with profile(s): 'production'
2014-04-26T19:30:46.899525+00:00 app[web.1]: Suppressed exit
2014-04-26T19:30:46.899112+00:00 app[web.1]: No :main namespace specified in project.clj.
2014-04-26T19:30:48.275513+00:00 heroku[web.1]: Process exited with status 1
2014-04-26T19:30:49.093441+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=floating-chamber-7585.herokuapp.com request_id=de532a37-57b1-4ce2-b5c0-c056019eda6b fwd="76.171.76.49" dyno= connect= service= status=503 bytes=
2014-04-26T19:30:48.303715+00:00 heroku[web.1]: State changed from starting to crashed
I have also tried explicitly setting the Procfile to 'lein ring server' (which is what you run in development). The error then is:
2014-04-26T21:24:34.229386+00:00 app[web.1]: java.lang.Exception: No namespace: heepster.view-helpers found
2014-04-26T21:24:34.221227+00:00 app[web.1]: :request-method :get
2014-04-26T21:24:34.221229+00:00 app[web.1]: :scheme :http
2014-04-26T21:24:34.221232+00:00 app[web.1]: :server-port 80
2014-04-26T21:24:34.221235+00:00 app[web.1]: :session/key nil
2014-04-26T21:24:34.229391+00:00 app[web.1]: at joodo.views$eval_content.invoke(views.clj:48)
2014-04-26T21:24:34.221238+00:00 app[web.1]: :uri /}
2014-04-26T21:24:34.229380+00:00 app[web.1]:
2014-04-26 21:24:34.227:WARN:oejs.AbstractHttpConnection:/
2014-04-26T21:24:34.229395+00:00 app[web.1]: at joodo.views$render_in_layout.invoke(views.clj:59)
2014-04-26T21:24:34.229388+00:00 app[web.1]: at clojure.core$the_ns.invoke(core.clj:3760)
2014-04-26T21:24:34.229401+00:00 app[web.1]: at heepster.main$fn__2523.invoke(main.clj:23)
2014-04-26T21:24:34.229405+00:00 app[web.1]: at compojure.core$if_route$fn__649.invoke(core.clj:40)
2014-04-26T21:24:34.229393+00:00 app[web.1]: at joodo.views$render.invoke(views.clj:52)
2014-04-26T21:24:34.229409+00:00 app[web.1]: at compojure.core$routing$fn__667.invoke(core.clj:107)
2014-04-26T21:24:34.229413+00:00 app[web.1]: at compojure.core$routing.doInvoke(core.clj:107)
2014-04-26T21:24:34.229397+00:00 app[web.1]: at joodo.views$render_template.doInvoke(views.clj:86)
2014-04-26T21:24:34.229403+00:00 app[web.1]: at compojure.core$make_route$fn__661.invoke(core.clj:94)
Does anyone have any ideas?

Resources