在我的GitHub CI中,我从今天开始收到如下错误:
File "/home/runner/.local/lib/python3.8/site-packages/fb4/login_bp.py", line 12, in <module>
from fb4.sqldb import db
File "/home/runner/.local/lib/python3.8/site-packages/fb4/sqldb.py", line 8, in <module>
db = SQLAlchemy()
File "/home/runner/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 758, in __init__
_include_sqlalchemy(self, query_class)
File "/home/runner/.local/lib/python3.8/site-packages/flask_sqlalchemy/__init__.py", line 112, in _include_sqlalchemy
for key in module.__all__:
AttributeError: module 'sqlalchemy' has no attribute '__all__'
CRITICAL: Exiting due to uncaught exception <class 'ImportError'>
没有意识到任何可能导致这种情况的重大承诺。我的本地测试和我的JenkinsCI仍然有效。
我修改了矩阵以坚持python 3.8,而不是同时尝试3.9、3.10和3.11,同时考虑到python 3.9 AttributeError: module 'posix' has no attribute 'all'中的类似问题是由于缺少3.9支持。
如何调试和缓解上述错误?
我的假设是问题出在setup/environment或者GitHub操作、Python、pip或者测试环境或者其他东西的一些奇怪的行为变化上。
本人是以下项目的委托人:
- https://github.com/WolfgangFahl/pyOnlineSpreadSheetEditing和潜在的
- https://github.com/WolfgangFahl/pyFlaskBootstrap4
**更新:**遵循@snakecharmerb的建议后,日志现在显示版本冲突
RROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts
The conflict is caused by:
The user requested Flask~=2.0.2
bootstrap-flask 1.8.0 depends on Flask
flask-dropzone 1.6.0 depends on Flask
flask-login 0.6.2 depends on Flask>=1.0.4
flask-httpauth 1.0.0 depends on Flask
flask-sqlalchemy 3.0.2 depends on Flask>=2.2
这很有趣,因为我试图避免~符号...事实上,这是一个打字错误...让我们看看是否修复升级Flask-SQLAlchemy〉=3.0.2现在工作。
按照建议设置版本后,我已经接受了答案。有后续问题,但问题得到了回答。
2条答案
按热度按时间5tmbdcev1#
在最近发布的SQLAlchemy 2.0中似乎删除了
.__all__
属性。您可能需要以某种方式将SQLAlchemy版本固定在配置中。或者确保您使用的是Flask-SQLAlchemy 3.0.2或更高版本,因为this issue建议该版本具有所需的修复。zd287kbt2#
我通过在flak-SQLAlchemy之前向我的需求添加特定版本的SQLAlchemy解决了这个问题。
我注意到pip正在安装2.0版本