Reputation: 15
I am trying to start my heroku app with a python flask app, but I am getting the h10 error and the only thing I can see in the log is the Tkinter not found but I am not using Tkinter in this project please help. I've been searching on the web and on other stack overflow questions, but most just say to make sure you don't declare a port or some js server thing. I haven't found anything that helps and when I read the log all I see is the Tkinter but I tried to purge it from my code but it still tries to call it.
2022-03-16T08:23:39.914386+00:00 heroku[web.1]: State changed from crashed to starting
2022-03-16T08:23:43.407711+00:00 heroku[web.1]: Starting process with command `gunicorn app:app`
2022-03-16T08:23:44.518553+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [4] [INFO] Starting gunicorn 20.1.0
2022-03-16T08:23:44.518954+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [4] [INFO] Listening at: http://0.0.0.0:46256 (4)
2022-03-16T08:23:44.518997+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [4] [INFO] Using worker: sync
2022-03-16T08:23:44.522063+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [9] [INFO] Booting worker with pid: 9
2022-03-16T08:23:44.585943+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [10] [INFO] Booting worker with pid: 10
2022-03-16T08:23:44.594660+00:00 heroku[web.1]: State changed from starting to up
2022-03-16T08:23:44.617799+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [9] [ERROR] Exception in worker process
2022-03-16T08:23:44.617801+00:00 app[web.1]: Traceback (most recent call last):
2022-03-16T08:23:44.617801+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-03-16T08:23:44.617802+00:00 app[web.1]: worker.init_process()
2022-03-16T08:23:44.617802+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2022-03-16T08:23:44.617803+00:00 app[web.1]: self.load_wsgi()
2022-03-16T08:23:44.617803+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-03-16T08:23:44.617804+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-03-16T08:23:44.617804+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-03-16T08:23:44.617804+00:00 app[web.1]: self.callable = self.load()
2022-03-16T08:23:44.617805+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-03-16T08:23:44.617805+00:00 app[web.1]: return self.load_wsgiapp()
2022-03-16T08:23:44.617805+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-03-16T08:23:44.617806+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-03-16T08:23:44.617806+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2022-03-16T08:23:44.617807+00:00 app[web.1]: mod = importlib.import_module(module)
2022-03-16T08:23:44.617807+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-03-16T08:23:44.617808+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-03-16T08:23:44.617809+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-03-16T08:23:44.617809+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-03-16T08:23:44.617809+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2022-03-16T08:23:44.617810+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2022-03-16T08:23:44.617810+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2022-03-16T08:23:44.617810+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2022-03-16T08:23:44.617811+00:00 app[web.1]: File "/app/app.py", line 4, in <module>
2022-03-16T08:23:44.617811+00:00 app[web.1]: from turtle import back
2022-03-16T08:23:44.617811+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/turtle.py", line 107, in <module>
2022-03-16T08:23:44.617811+00:00 app[web.1]: import tkinter as TK
2022-03-16T08:23:44.617812+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/tkinter/__init__.py", line 37, in <module>
2022-03-16T08:23:44.617812+00:00 app[web.1]: import _tkinter # If this fails your Python may not be configured for Tk
2022-03-16T08:23:44.617812+00:00 app[web.1]: ModuleNotFoundError: No module named '_tkinter'
2022-03-16T08:23:44.617924+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [9] [INFO] Worker exiting (pid: 9)
2022-03-16T08:23:44.626229+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [10] [ERROR] Exception in worker process
2022-03-16T08:23:44.626231+00:00 app[web.1]: Traceback (most recent call last):
2022-03-16T08:23:44.626232+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/arbiter.py", line 589, in spawn_worker
2022-03-16T08:23:44.626232+00:00 app[web.1]: worker.init_process()
2022-03-16T08:23:44.626233+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 134, in init_process
2022-03-16T08:23:44.626233+00:00 app[web.1]: self.load_wsgi()
2022-03-16T08:23:44.626233+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/workers/base.py", line 146, in load_wsgi
2022-03-16T08:23:44.626234+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2022-03-16T08:23:44.626234+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/base.py", line 67, in wsgi
2022-03-16T08:23:44.626234+00:00 app[web.1]: self.callable = self.load()
2022-03-16T08:23:44.626235+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 58, in load
2022-03-16T08:23:44.626235+00:00 app[web.1]: return self.load_wsgiapp()
2022-03-16T08:23:44.626235+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/app/wsgiapp.py", line 48, in load_wsgiapp
2022-03-16T08:23:44.626236+00:00 app[web.1]: return util.import_app(self.app_uri)
2022-03-16T08:23:44.626236+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/site-packages/gunicorn/util.py", line 359, in import_app
2022-03-16T08:23:44.626236+00:00 app[web.1]: mod = importlib.import_module(module)
2022-03-16T08:23:44.626237+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/importlib/__init__.py", line 127, in import_module
2022-03-16T08:23:44.626237+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2022-03-16T08:23:44.626238+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
2022-03-16T08:23:44.626238+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
2022-03-16T08:23:44.626238+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
2022-03-16T08:23:44.626239+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
2022-03-16T08:23:44.626239+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 850, in exec_module
2022-03-16T08:23:44.626239+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
2022-03-16T08:23:44.626240+00:00 app[web.1]: File "/app/app.py", line 4, in <module>
2022-03-16T08:23:44.626240+00:00 app[web.1]: from turtle import back
2022-03-16T08:23:44.626240+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/turtle.py", line 107, in <module>
2022-03-16T08:23:44.626241+00:00 app[web.1]: import tkinter as TK
2022-03-16T08:23:44.626241+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.9/tkinter/__init__.py", line 37, in <module>
2022-03-16T08:23:44.626242+00:00 app[web.1]: import _tkinter # If this fails your Python may not be configured for Tk
2022-03-16T08:23:44.626242+00:00 app[web.1]: ModuleNotFoundError: No module named '_tkinter'
2022-03-16T08:23:44.626370+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [10] [INFO] Worker exiting (pid: 10)
2022-03-16T08:23:44.660683+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [4] [WARNING] Worker with pid 10 was terminated due to signal 15
2022-03-16T08:23:44.759567+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [4] [INFO] Shutting down: Master
2022-03-16T08:23:44.759605+00:00 app[web.1]: [2022-03-16 08:23:44 +0000] [4] [INFO] Reason: Worker failed to boot.
2022-03-16T08:23:44.900215+00:00 heroku[web.1]: Process exited with status 3
2022-03-16T08:23:44.961553+00:00 heroku[web.1]: State changed from up to crashed
2022-03-16T08:23:46.285089+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=uab3v3tournament.herokuapp.com request_id=fbc0a20c-6c92-4455-b730-0d57397cde41 fwd="50.86.240.117" dyno= connect= service= status=503 bytes= protocol=https
2022-03-16T08:23:46.960838+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=uab3v3tournament.herokuapp.com request_id=15532e96-e63b-44d5-8f2a-8ec26cffee08 fwd="50.86.240.117" dyno= connect= service= status=503 bytes= protocol=https
2022-03-16T08:23:47.166898+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=uab3v3tournament.herokuapp.com request_id=0b46786b-0c9b-43fd-ba78-07110a6f0b31 fwd="50.86.240.117" dyno= connect= service= status=503 bytes=
protocol=https
web: gunicorn app:app
click==8.0.4
colorama==0.4.4
Flask==2.0.3
Flask-Admin==1.6.0
Flask-Login==0.5.0
Flask-SQLAlchemy==2.5.1
Flask-WTF==1.0.0
greenlet==1.1.2
gunicorn==20.1.0
itsdangerous==2.1.0
Jinja2==3.0.3
MarkupSafe==2.1.0
SQLAlchemy==1.4.32
Werkzeug==2.0.3
WTForms==3.0.1
from distutils.command.sdist import sdist
from enum import unique
from genericpath import exists
from turtle import back
from flask_admin import Admin, AdminIndexView
from flask_admin.contrib.sqla import ModelView
from wtforms import Form, BooleanField, StringField, PasswordField, validators
from flask import Flask, redirect, render_template, session, url_for, request, flash
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime
from sqlalchemy import ForeignKey, select
from datetime import datetime
import sqlite3
import os
from flask import g, send_from_directory
from flask_login import login_required, login_user, current_user, login_manager, logout_user, UserMixin, LoginManager
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI']= 'sqlite:///test.db'
db = SQLAlchemy(app)
app.config['SECRET_KEY'] = 'sdafwer3rw93ur9wu0er339de'
admin = Admin(app, url = '/sakjhfajsewdsjasfe')
#sakjhfajsewdsjasfe
class Forms(db.Model):
__tablename__ = 'forms'
id = db.Column(db.Integer, primary_key = True)
names = db.Column(db.String(200), nullable = False)
emails = db.Column(db.String(200), unique = False)
team_name_id = db.Column(db.Integer, db.ForeignKey('team_names.id'))
def __repr__(self):
return '<Forms %r>' % self.id
def __init__(self, names, emails, team_names):
self.names = names
self.emails = emails
self.team_names = team_names
class Team_names(db.Model):
__tablename__ = 'team_names'
id = db.Column(db.Integer, primary_key = True)
team_name = db.Column(db.String(200), unique = True)
formss = db.relationship('Forms', backref = 'team_names', lazy=True)
def __repr__(self):
return '<Team_names %r>' % self.id
def __init__(self, team_name):
self.team_name = team_name
admin.add_view(ModelView(Forms, db.session))
admin.add_view(ModelView(Team_names, db.session))
@app.route('/favicon.ico')
def favicon():
return send_from_directory(os.path.join(app.root_path, 'static'), 'favicon.ico', mimetype='image/icon.png')
@app.route('/starthere', methods=['POST','GET'])
def first():
return render_template('first.html')
@app.route('/new', methods=['POST','GET'])
def new():
if request.method == 'POST':
givenname = request.form['names']
givenemail = request.form['emails']
giventeamnames = request.form['team_names']
adding1 = Team_names(team_name = giventeamnames)
adding = Forms(names = givenname, emails = givenemail, team_names=adding1)
try:
db.session.add(adding)
db.session.add(adding1)
db.session.commit()
return render_template('thankyou.html')
except:
return render_template('fail1.html')
else:
return render_template('new.html')
@app.route('/join', methods=['POST','GET'])
def join():
teams = Team_names.query.with_entities(Team_names.team_name)
for team in teams:
team = Team_names.team_name
if request.method == 'POST':
givennames = request.form['names']
givenemails = request.form['emails']
select = request.form.get("selected")
selected_team = db.session.query(Team_names).filter(Team_names.team_name == select).first()
adding = Forms(names = givennames, emails = givenemails, team_names = selected_team)
try:
db.session.add(adding)
db.session.commit()
return render_template('thankyou.html')
except:
return render_template('fail2.html')
else:
return render_template("join.html", teams=teams)
if __name__ == "__main__":
app.run(debug=True)
Upvotes: 0
Views: 378
Reputation: 136938
The immediate problem is caused by the following import:
from turtle import back
It doesn't make much sense to use the turtle
module in a web application. Fortunately, you don't seem to actually be using it.
Remove that line, commit, and redeploy.
Once that's done, you will probably find that your SQLite database doesn't behave as you expect it to.
Heroku's ephemeral filesystem makes file-based databases like SQLite a poor choice. A client-server database like PostgreSQL will work much better. Heroku's own Postgres service might be a good place to start.
Upvotes: 1