我正在使用flask-admin 和flask-sqlalchemy 开发一个小型flask API。 api 运行良好,但每当我安装新包时,我都会遇到错误。
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask/cli.py", line 218, in locate_app
__import__(module_name)
File "/Users/brandoncreed/Desktop/Brandon Coding Projects/management-System/src/app.py", line 12, in <module>
from api.admin import setup_admin
File "/Users/brandoncreed/Desktop/Brandon Coding Projects/management-System/src/api/admin.py", line 5, in <module>
from flask_admin.contrib.sqla import ModelView
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask_admin/contrib/sqla/__init__.py", line 2, in <module>
from .view import ModelView
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask_admin/contrib/sqla/view.py", line 18, in <module>
from flask_admin.contrib.sqla.tools import is_relationship
File "/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/flask_admin/contrib/sqla/tools.py", line 11, in <module>
from sqlalchemy.ext.associationproxy import ASSOCIATION_PROXY
ImportError: cannot import name 'ASSOCIATION_PROXY' from 'sqlalchemy.ext.associationproxy' (/Users/brandoncreed/.local/share/virtualenvs/management-System-Wyc_ba1N/lib/python3.8/site-packages/sqlalchemy/ext/associationproxy.py)
我不确定是什么原因造成的,但安装新软件包后,flask_admin 和 sqlalchemy 之间似乎存在冲突。我删除了虚拟环境中的 pipfile.lock 并运行 Pipenv install 以查看新文件是否有效,但它不起作用。我还尝试卸载新软件包以查看是否可以解决问题,但相同的错误仍然存在。我想知道这是否与更新 Flask-admin 或 sqlalchemy 有关。