I've searched online but haven't found anything that fixed my issue. I'm writing a web app in Flask using Python, but after transferring my data to a new computer and recreating the virtual environment, I'm no longer able to use Flask's built-in development web server. I'm getting the traceback below. I can't tell if the issue lies in the SQL or Flask modules, but I've tried reinstalling and compiling them from source to no avail. The application throws the same error even when not in the virtual environment, as well.
127.0.0.1 - - [07/Aug/2020 14:29:49] "GET / HTTP/1.1" 500 -
Traceback (most recent call last):
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/util/_collections.py", line 1020, in __call__
return self.registry[key]
KeyError: 139700690765568
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
return self.finalize_request(rv)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py", line 1969, in finalize_request
response = self.process_response(response)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask/app.py", line 2268, in process_response
self.session_interface.save_session(self, ctx.session, response)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_session/sessions.py", line 534, in save_session
saved_session = self.sql_session_model.query.filter_by(
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 519, in __get__
return type.query_class(mapper, session=self.sa.session())
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/orm/scoping.py", line 78, in __call__
return self.registry()
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/util/_collections.py", line 1022, in __call__
return self.registry.setdefault(key, self.createfunc())
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/orm/session.py", line 3286, in __call__
return self.class_(**local_kw)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 138, in __init__
bind = options.pop('bind', None) or db.engine
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 937, in engine
return self.get_engine()
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 956, in get_engine
return connector.get_engine()
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 561, in get_engine
self._engine = rv = self._sa.create_engine(sa_url, options)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 966, in create_engine
return sqlalchemy.create_engine(sa_url, **engine_opts)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/engine/__init__.py", line 500, in create_engine
return strategy.create(*args, **kwargs)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 87, in create
dbapi = dialect_cls.dbapi(**dbapi_args)
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/sqlalchemy/dialects/mysql/mysqldb.py", line 118, in dbapi
return __import__("MySQLdb")
File "/home/jhonig/ttx/venv/lib/python3.8/site-packages/MySQLdb/__init__.py", line 18, in <module>
from . import _mysql
ImportError: /lib/x86_64-linux-gnu/libstdc++.so.6: cannot allocate memory in static TLS block
For anyone who might come across this issue, there was an issue with the libmysqlclient21
package, which was fixed in the 8.0.21
version:
Bug: https://bugs.launchpad.net/ubuntu/+source/opencv/+bug/1890170
Fix: https://bugs.launchpad.net/ubuntu/+source/mysql-8.0/+bug/1889851