当前位置: 首页>后端>正文

sqlalchemy报错 ModuleNotFoundError- No module named 'urlparse'

环境依赖
python3.8.10
flask==1.1.4
sqlalchemy==0.8.0

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "H:\CodeSpace\learn\message-board\app.py", line 5, in <module>
    from flask_sqlalchemy import SQLAlchemy
  File "H:\CodeSpace\learn\hello\.venv\lib\site-packages\flask_sqlalchemy\__init__.py", line 13, in <module>
    import sqlalchemy
  File "H:\CodeSpace\learn\hello\.venv\lib\site-packages\sqlalchemy\__init__.py", line 10, in <module>
    from .sql import (
  File "H:\CodeSpace\learn\hello\.venv\lib\site-packages\sqlalchemy\sql\__init__.py", line 7, in <module>
    from .expression import (
  File "H:\CodeSpace\learn\hello\.venv\lib\site-packages\sqlalchemy\sql\expression.py", line 34, in <module>
    from .. import util, exc, inspection
  File "H:\CodeSpace\learn\hello\.venv\lib\site-packages\sqlalchemy\util\__init__.py", line 7, in <module>
    from .compat import callable, cmp, reduce,  \
  File "H:\CodeSpace\learn\hello\.venv\lib\site-packages\sqlalchemy\util\compat.py", line 62, in <module>
    from urlparse import parse_qsl
ModuleNotFoundError: No module named 'urlparse'

出现这个问题的原因是python3中不支持from urlparse import parse_qsl这个写法,取而代之的是from urllib.parse import parse_qsl

解决办法:
升级sqlalchemy版本到sqlalchemy = "1.3.24"


https://www.xamrdz.com/backend/3db1936716.html

相关文章: