nonebot / adapter-qq

NoneBot2 QQ 适配器 / QQ adapter for nonebot2
MIT License
205 stars 18 forks source link

不能启动 #112

Closed gaodeng520 closed 1 month ago

gaodeng520 commented 1 month ago

.env规定Env=Prod .env.prod规定 DRIVER=~httpx+~websockets 但是启动提示

Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\bot\adengnb\.venv\Lib\site-packages\nonebot\drivers\fastapi.py", line 38, in <module>
    import uvicorn
ModuleNotFoundError: No module named 'uvicorn'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "C:\Users\Administrator\Desktop\bot\adengnb\.venv\Lib\site-packages\nonebot\__init__.py", line 318, in init
    DriverClass = _resolve_combine_expr(config.driver)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\Desktop\bot\adengnb\.venv\Lib\site-packages\nonebot\__init__.py", line 254, in _resolve_combine_expr
    DriverClass = resolve_dot_notation(
                  ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\Desktop\bot\adengnb\.venv\Lib\site-packages\nonebot\utils.py", line 264, in resolve_dot_notation
    module = importlib.import_module(modulename)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "C:\Users\Administrator\Desktop\bot\adengnb\.venv\Lib\site-packages\nonebot\drivers\fastapi.py", line 43, in <module>
    raise ImportError(
ImportError: Please install FastAPI first to use this driver. Install with pip: `pip install nonebot2[fastapi]`

安装后启动项目又提示这个 RuntimeError: Current driver ~fastapi does not support http client requests! QQ Adapter need a HTTPClient Driver to work.

后续我又尝试了aiohttp,但问题依然没有解决

he0119 commented 1 month ago

设置 DRIVER=~httpx+~websockets 后你需要 pip install nonebot2[httpx,websockets] 安装相应依赖。aiohttp 同理。

yanyongyu commented 1 month ago

你需要安装对应nb依赖,另外从你的日志看,你的driver配置并没有生效。

gaodeng520 commented 1 month ago

我竟然有点不敢相信自己,凡是.env.prod文件的第一行配置都会被加上\ufeff 但是.env就不会 应该是用记事本修改文件编码造成的,所以尽量不要用记事本!