Stack Overflow Asked by David Wolever on November 4, 2021
After re-building a Docker image, I’ve started to get the following error:
$ docker run --rm -it python:3.8-slim /bin/bash
...
$ pip install flask_sqlalchemy
...
$ python -c "from flask_sqlalchemy import SQLAlchemy; SQLAlchemy()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 715, in __init__
self.Model = self.make_declarative_base(model_class, metadata)
File "/usr/local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 797, in make_declarative_base
model.query_class = self.Query
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/ext/declarative/api.py", line 79, in __setattr__
_add_attribute(cls, key, value)
File "/usr/local/lib/python3.8/site-packages/sqlalchemy/ext/declarative/base.py", line 802, in _add_attribute
type.__setattr__(cls, key, value)
TypeError: can't apply this __setattr__ to DefaultMeta object
The versions of the specific packages involved:
python -c "import sqlalchemy, flask_sqlalchemy; print(sqlalchemy.__version__, flask_sqlalchemy.__version__)"
1.3.18 # sqlalchemy
2.4.3 # flask_sqlalchemy
Although I’ve also experienced the error with versions 1.3.17
and 2.4.1
.
After some experimentation, it seems like the issue is due to some change between python:3.8.3-slim
and python:3.8.4-slim
.
To reproduce, notice that this works:
$ docker run --rm -it python:3.8.3-slim …
Where this does not:
docker run --rm -it python:3.8.4-slim …
It looks like this bug/fix is the cause of the issue: https://bugs.python.org/issue39960
Answered by David Wolever on November 4, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP