一、问题描述
python3.9.12 执行 import nonebot
报错信息如下:
Traceback (most recent call last):
File "/root/yxn/root/CQ-GO/QQRobot/bot.py", line 6, in <module>
import nonebot
File "/usr/local/python3/lib/python3.9/site-packages/nonebot/__init__.py", line 7, in <module>
import aiocqhttp
File "/usr/local/python3/lib/python3.9/site-packages/aiocqhttp/__init__.py", line 19, in <module>
from quart import Quart, request, abort, jsonify, websocket, Response
File "/usr/local/python3/lib/python3.9/site-packages/quart/__init__.py", line 3, in <module>
from jinja2 import escape, Markup
ImportError: cannot import name 'escape' from 'jinja2'
经过检测后发现是版本问题,更新就ok了
二、问题解决(win和linux大同小异)
执行以下代码:
pip install -U aiocphttp quart jinja2
若提示未找到
Could not find a version that satisfies the requirement aiocphttp
ERROR: No matching distribution found for aiocphttp
把aiocphttp卸载了重新安装就好了
pip uninstall aiocphttp quart jinja2 -y
pip install aiocphttp quart jinja2
pip install ujson
pip install msgpack
三、完美解决
四、完整指令如下(顺序执行):
pip uninstall aiocqhttp -y
pip install aiocqhttp
pip install -U quart
pip install ujson
pip install msgpack
顺带吐槽一句这个解决的什么啊https://ask.csdn.net/questions/7684357,不知道就不要乱答乱采纳