ImportError:无法从“sqlalchemy.engine”导入名称“URL”

Ken*_*y_I 3 python sqlalchemy

为什么我无法使 sqlalchemy.engine 正常工作?

我已经安装了 SQLAlchemy

 pip install SQLAlchemy
Run Code Online (Sandbox Code Playgroud)

我在Python中有以下代码

 from sqlalchemy.engine import URL
Run Code Online (Sandbox Code Playgroud)

它会导致错误:

ImportError: cannot import name 'URL' from 'sqlalchemy.engine' (C:\Python\Python3.8.9\lib\site- 
packages\sqlalchemy\engine\__init__.py)
Run Code Online (Sandbox Code Playgroud)

小智 5

尝试使用以下命令安装它:

pip3 install flask-sqlalchemy

如果它不起作用,请尝试在两个命令末尾加上 --user 的上述命令。

pip3 install flask-sqlalchemy --user