起因
原来nonebot用的好好的,用pycharm安装一下flask框架,再运行nonebot出现这样的报错
Console output is saving to: C:\Users\11025\Desktop\Sam_Bot\HoshinoBot\log
Traceback (most recent call last):
File "C:/Users/11025/Desktop/Sam_Bot/HoshinoBot/run.py", line 1, in <module>
import hoshino
File "C:\Users\11025\Desktop\Sam_Bot\HoshinoBot\hoshino\__init__.py", line 3, in <module>
import nonebot
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\nonebot\__init__.py", line 7, in <module>
import aiocqhttp
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\aiocqhttp\__init__.py", line 19, in <module>
from quart import Quart, request, abort, jsonify, websocket, Response
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\quart\__init__.py", line 6, in <module>
from .app import Quart
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\quart\app.py", line 46, in <module>
from .asgi import ASGIHTTPConnection, ASGILifespan, ASGIWebsocketConnection
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\quart\asgi.py", line 29, in <module>
from .debug import traceback_response
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\quart\debug.py", line 8, in <module>
from .wrappers import Response
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\quart\wrappers\__init__.py", line 3, in <module>
from .base import BaseRequestWebsocket
File "C:\Users\11025\AppData\Local\Programs\Python\Python38\lib\site-packages\quart\wrappers\base.py", line 7, in <module>
from werkzeug.sansio.request import Request as SansIORequest
ModuleNotFoundError: No module named 'werkzeug.sansio'
进程已结束,退出代码1
怀疑模块没有安装,重新安装werkzeug.sansio
,但是提示已经安装了
解决方法
开始饶头,然后Google了一下
发现可能是版本的问题
py -3.8 -m pip uninstall werkzeug
Found existing installation: Werkzeug 1.0.1
Uninstalling Werkzeug-1.0.1:
Would remove:
c:\users\11025\appdata\local\programs\python\python38\lib\site-packages\werkzeug-1.0.1.dist-info\*
c:\users\11025\appdata\local\programs\python\python38\lib\site-packages\werkzeug\*
Proceed (Y/n)? Y
Successfully uninstalled Werkzeug-1.0.1
然后卸载后重新安装
请输入你需要pip的软件包:werkzeug
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting werkzeug
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/f4/f3/22afbdb20cc4654b10c98043414a14057cd27fdba9d4ae61cea596000ba2/Werkzeug-2.0.3-py3-none-any.whl (289 kB)
Installing collected packages: werkzeug
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
flask 1.1.4 requires Werkzeug<2.0,>=0.15, but you have werkzeug 2.0.3 which is incompatible.
aiocqhttp 1.4.2 requires Quart<0.15,>=0.14, but you have quart 0.16.3 which is incompatible.
Successfully installed werkzeug-2.0.3
----------------------------success----------------------------
再次重启发现还是原来的报错,怀疑没有卸载干净,
重新运行卸载指令,卸载werkzeug
和Werkzeug
,
首字母大写小写的包都卸载一遍才可以,不知道什么玄学bug
然后重新安装werkzeug
,启动nonebot 这一次没有报错。
总结
因为安装flask
包导致的werkzeug
包的的版本问题,下次记得使用虚拟环境~
感谢
Gooole->ModuleNotFoundError: No module named 'werkzeug.sansio'GitHub->issues->#16 ModuleNotFoundError: No module named 'werkzeug.contrib'