Heroku: no module named flask though it is in requirements.txt - heroku

Can anyone help with this error on Heroku?
2015-01-12T22:26:00.575669+00:00 heroku[web.1]: Starting process with command `python hangman.py`
2015-01-12T22:26:01.066240+00:00 app[web.1]: Traceback (most recent call last):
2015-01-12T22:26:01.066256+00:00 app[web.1]: File "hangman.py", line 3, in <module>
2015-01-12T22:26:01.066262+00:00 app[web.1]: from flask import (
2015-01-12T22:26:01.066268+00:00 app[web.1]: ImportError: No module named flask
2015-01-12T22:26:01.742444+00:00 heroku[web.1]: Process exited with status 1
2015-01-12T22:26:01.751614+00:00 heroku[web.1]: State changed from starting to crashed
My git repo is here: https://github.com/PJBentham/Hangman
I believe I have done everything correct as far as set up is concerned but I'm still getting the above error and can't figure out why?

You have to show the last or pull traceback to debug further ...! You git repo working perfectly fine.
From your traceback snippet flask is not there. Check if your app environ having flask or not using heroku run pip freeze

Related

My Spider crashes whenever I schedule to production on Heroku

My spider is working both on the local machine and on the Heroku platform, however, I wish to schedule the spider so it works according to the time given through cron expression.
This is my periodic_requests.py file:
from pytz import timezone
import requests, pytz
from apscheduler.schedulers.twisted import TwistedScheduler
from twisted.internet import reactor
def send_request():
requests.post(
url="https://datacrawlapp.herokuapp.com/schedule.json",
data={"project":"datahubsitecrawler",
"spider":"datahubcrawlapp",
"data_url": "https://drive.google.com/file/d/1zBfsWZdoFzoAq6ZELfw-tvvBFcVmCMI7/view?usp=sharing"
}
)
if __name__ == '__main__':
scheduler = TwistedScheduler(timezone=pytz.utc),
scheduler.add_job(send_request, 'cron', day_of_week='mon-sun', hour='19', minute='47')
scheduler.start()
try:
reactor.run() # the script will block here until the crawling is finished
except (KeyboardInterrupt, SystemExit):
pass
Procfile:
web: scrapyd
clock: python periodic_requests
I get error:
File "/app/.heroku/python/lib/python3.8/site-packages/scrapyd/website.py", line 212,
in prep_tab_finished
2022-02-07T08:58:06.697647+00:00 app[web.1]: return '\n'.join(
2022-02-07T08:58:06.697647+00:00 app[web.1]: builtins.TypeError: 'NoneType' object is not iterable:
and then it crashes as shown below:
2022-02-07T08:48:32.411005+00:00 heroku[web.1]: State changed from starting to up
2022-02-07T08:48:32.611649+00:00 heroku[clock.1]: Process exited with status 0
2022-02-07T08:48:32.721748+00:00 heroku[clock.1]: State changed from up to crashed
2022-02-07T08:48:32.742567+00:00 heroku[clock.1]: State changed from crashed to starting
2022-02-07T08:48:41.000000+00:00 app[api]: Build succeeded
2022-02-07T08:48:42.473990+00:00 heroku[clock.1]: Starting process with command `python periodic_requests.py`
2022-02-07T08:48:43.195961+00:00 heroku[clock.1]: State changed from starting to up
2022-02-07T08:48:44.920927+00:00 heroku[clock.1]: Process exited with status 0
2022-02-07T08:48:44.984024+00:00 heroku[clock.1]: State changed from up to crashed
Will appreciate your help!

Why is the bot on Heroku Server not responding?

I programmed a simple bot that is connected to Google Sheets API. It asks a few questions to the user and stores it in the Sheet I have. When I use bot.polling it works fine, but I was trying the webhook so I could use Heroku to have my bot running 24/7.
I introduced the code:
#server.route('/' + token, methods=['POST'])
def getMessage():
bot.process_new_updates([telebot.types.Update.de_json(request.stream.read().decode("utf-8"))])
return "!", 200
#server.route("/")
def webhook():
bot.remove_webhook()
bot.set_webhook(url = '<Heroku App Link>' + token)
return "!", 200
if __name__ == "__main__":
server.run(host="0.0.0.0", port = int(os.environ.get('PORT', 5000)))
I have the requirements.txt file and the Procfile that currently is like this:
web: python3 bot.py
I tried a bunch of things in the Procfile but this is the only one that didn't gave an error.
When I saw the log this is what I got:
2019-09-24T10:18:54.369238+00:00 heroku[web.1]: State changed from crashed to starting
2019-09-24T10:19:04.416777+00:00 heroku[web.1]: Starting process with command `python3 bot.py`
2019-09-24T10:19:09.868915+00:00 heroku[web.1]: State changed from starting to up
2019-09-24T10:19:09.790773+00:00 app[web.1]: * Serving Flask app "bot" (lazy loading)
2019-09-24T10:19:09.790800+00:00 app[web.1]: * Environment: production
2019-09-24T10:19:09.790853+00:00 app[web.1]: WARNING: This is a development server. Do not use it in a production deployment.
2019-09-24T10:19:09.790940+00:00 app[web.1]: Use a production WSGI server instead.
2019-09-24T10:19:09.790991+00:00 app[web.1]: * Debug mode: off
2019-09-24T10:19:09.799470+00:00 app[web.1]: * Running on http://0.0.0.0:57826/ (Press CTRL+C to quit)
2019-09-24T10:19:15.000000+00:00 app[api]: Build succeeded
Can anyone help me understand why the bot doesn't answer any commands?

Flask web app getting error on Heroku but working on localhost

I have a Flask web app that's running perfectly fine on localhost. When I deployed to Heroku, it was a successful build. However, when I opened the web app, there was an error. This was the log message:
2016-11-21T07:17:17.106395+00:00 app[web.1]: File "/app/routes.py", line 2, in <module>
2016-11-21T07:17:17.106395+00:00 app[web.1]: from data import SearchBar, CourseData
2016-11-21T07:17:17.106395+00:00 app[web.1]: File "/app/data.py", line 1, in <module>
2016-11-21T07:17:17.106396+00:00 app[web.1]: from flask_wtf import Form
2016-11-21T07:17:17.106396+00:00 app[web.1]: ImportError: No module named flask_wtf
I have WTForms installed. I'm not sure why it's not running on Heroku, though it's running fine on localhost.

uploading web.py app on Heroku

just started on using web.py and heroku, so...
I have this simple app that I want to upload to heroku and I have followed the instruction from http://joshuaoiknine.com/post/47196802362/publishing-for-the-web-py-python-framework-to-heroku
This is my Procfile:
web: python code.py $PATH
But after I uploaded it to heroku, it gives me the application error.
The heroku log shows me this:
2013-08-08T03:27:44.956675+00:00 heroku[web.1]: Starting process with command `python code.py /usr/local/bin:/usr/bin:/bin`
2013-08-08T03:27:45.673358+00:00 app[web.1]: Traceback (most recent call last):
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "code.py", line 52, in <module>
2013-08-08T03:27:45.673358+00:00 app[web.1]: app.run()
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/web/application.py", line 313, in run
2013-08-08T03:27:45.673358+00:00 app[web.1]: return wsgi.runwsgi(self.wsgifunc(*middleware))
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/web/wsgi.py", line 54, in runwsgi
2013-08-08T03:27:45.673358+00:00 app[web.1]: return httpserver.runsimple(func, validip(listget(sys.argv, 1, '')))
2013-08-08T03:27:45.673358+00:00 app[web.1]: File "/app/.heroku/python/lib/python2.7/site-packages/web/net.py", line 76, in validip
2013-08-08T03:27:45.673358+00:00 app[web.1]: port = int(port)
2013-08-08T03:27:45.673552+00:00 app[web.1]: ValueError: invalid literal for int() with base 10: '/usr/local/bin:/usr/bin:/bin'
2013-08-08T03:27:46.866238+00:00 heroku[web.1]: Process exited with status 1
2013-08-08T03:27:46.881655+00:00 heroku[web.1]: State changed from starting to crashed
However, when i tried the second method, I receive this error:
Traceback (most recent call last):
File "code.py", line 55, in <module>
app.run(host='0.0.0.0', port=port)
TypeError: run() got an unexpected keyword argument 'host'
Any ideas how to get my app onto heroku up and running?
code.py expects an integer argument first, not your $PATH. It is probably a port it is expecting, so instead of $PATH in your Procfile pass $PORT.
Even better: change your code to use ENV["PORT"] and if that's not defined (as might be the case in your local dev env) then a default (say, 8000 or 8080 for your dev env).
On Heroku, the port your server needs to listen on is not fixed -- it changes with every restart of every dyno. Heroku will set the environment variable PORT to let you know which port to listen on.

Deploying Play 2.0 app on Heroku

So I am kind of new to setting up servers. And I have been struggling with various sql issues all night. I think the only thing that sits between me and a successfully running play app is this: error
Starting process with command `target/start -Dhttp.port=80 `
2012-04-04T05:58:52+00:00 app[web.1]: Play server process ID is 1
2012-04-04T05:58:53+00:00 app[web.1]: [info] play - database [default] connected at jdbc:mysql://us-cdbr-east.cleardb.com/heroku_cd914b667dae168
2012-04-04T05:58:56+00:00 app[web.1]: [info] play - Application started (Prod)
2012-04-04T05:58:56+00:00 app[web.1]: Oops, cannot start the server.
2012-04-04T05:58:56+00:00 app[web.1]: org.jboss.netty.channel.ChannelException: Failed to bind to: /0.0.0.0:80
... more errors
Does anyone spot any problems? Do I need any java options arguments?
I tried specifying a user port in the Procfile, and got a different error message:
2012-04-04T07:01:36+00:00 heroku[web.1]: Starting process with command `target/start -Dhttp.port=2000`
2012-04-04T07:01:37+00:00 app[web.1]: Play server process ID is 1
2012-04-04T07:01:40+00:00 app[web.1]: [info] play - database [default] connected at jdbc:mysql://us-cdbr-east.cleardb.com/heroku_cd914b667dae168
2012-04-04T07:01:45+00:00 app[web.1]: [info] play - Application started (Prod)
2012-04-04T07:01:45+00:00 app[web.1]: [info] play - Listening for HTTP on port 2000...
2012-04-04T07:01:46+00:00 heroku[web.1]: Error R11 (Bad bind) -> Process bound to port 2000, should be 47248 (see environment variable PORT)
2012-04-04T07:01:46+00:00 heroku[web.1]: Stopping process with SIGKILL
2012-04-04T07:01:47+00:00 heroku[web.1]: Process exited with status 137
2012-04-04T07:01:47+00:00 heroku[web.1]: State changed from starting to crashed
I have no idea what is happening. How do I change this environment variable? This heroku process model is very confusing to me.
I think the problem is that you're not allowing Heroku to specify the port. Googling your error I find: https://devcenter.heroku.com/articles/error-codes#r11__bad_bind
So instead of doing this:
web: target/start -Dhttp.port=80
Do this
web: target/start -Dhttp.port=$PORT
James has a nice writeup on getting a more advanced Play 2.0 app deployed here.

Resources