从今天起,我在 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'>
Run Code Online (Sandbox Code Playgroud)
不知道任何可能导致这种情况的重大提交。我的本地测试和 Jenkins CI 仍然有效。
我更改了矩阵以坚持使用 python 3.8,而不是尝试 3.9、3.10 和 3.11,还考虑到python 3.9 AttributeError: module 'posix' has no attribute '__all__'中的类似问题是由于缺少 3.9 支持。
如何调试和缓解上述错误?
我的假设是问题出在设置/环境中,或者 …
我正在学习 Flask 的全栈课程。我的init .py 看起来像:
from flask import Flask
from config import Config
from flask_mongoengine import MongoEngine
app = Flask(__name__)
app.config.from_object(Config)
db = MongoEngine()
db.init_app(app)
from application import routes
Run Code Online (Sandbox Code Playgroud)
但是,在导入时from flask_mongoengine import MongoEngine,我收到 ImportError:
ImportError: cannot import name 'JSONEncoder' from 'flask.json'
Run Code Online (Sandbox Code Playgroud)
我的 venv 看起来像:
blinker==1.6.2
click==8.1.3
colorama==0.4.6
dnspython==2.3.0
email-validator==2.0.0.post2
Flask==2.3.2
flask-mongoengine==1.0.0
Flask-WTF==1.1.1
idna==3.4
itsdangerous==2.1.2
Jinja2==3.1.2
MarkupSafe==2.1.3
mongoengine==0.27.0
pymongo==4.4.0
python-dotenv==1.0.0
Werkzeug==2.3.6
WTForms==3.0.1
Run Code Online (Sandbox Code Playgroud)
我可以在这里做些什么来避免这种冲突吗?谢谢!