Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

搜图报错下载失败 TypeError: Current driver does not support http client #136

Closed
In-dor opened this issue Aug 10, 2024 · 3 comments
Closed
Labels
question Further information is requested

Comments

@In-dor
Copy link

In-dor commented Aug 10, 2024

YetAnotherPicSearch 、 PicImageSearch 、 go-cqhttp 、 nonebot 、 Python 版本及操作系统

YetAnotherPicSearch 2.0.0
NapCat 1.8.6
nonebot 2.3.2
Python 3.10.11
Windows 11 24H2

列出安装的 Python 包

No response

如何复现

直接搜图

期望行为

No response

实际行为

image

08-10 19:32:50 [ERROR] YetAnotherPicSearch | Error occurred
Traceback (most recent call last):
  File "<string>", line 15, in <module>
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\__init__.py", line 335, in run
    get_driver().run(*args, **kwargs)
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 186, in run
    uvicorn.run(
  File "F:\ResonaBot\.venv\lib\site-packages\uvicorn\main.py", line 568, in run
    server.run()
  File "F:\ResonaBot\.venv\lib\site-packages\uvicorn\server.py", line 59, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\Python310\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Python310\lib\asyncio\base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "C:\Python310\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\Python310\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\Python310\lib\asyncio\base_events.py", line 1909, in _run_once
    handle._run()
  File "C:\Python310\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\message.py", line 476, in check_and_run_matcher
    await _run_matcher(
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\message.py", line 428, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 850, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\internal\matcher\matcher.py", line 825, in simple_run
    await handler(
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\dependencies\__init__.py", line 94, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "F:\ResonaBot\.venv\lib\site-packages\YetAnotherPicSearch\__main__.py", line 319, in search_handler
    await handle_single_image(
  File "F:\ResonaBot\.venv\lib\site-packages\YetAnotherPicSearch\__main__.py", line 282, in handle_single_image
    if (not file) and (not (file := await fetch_image(seg))):
  File "F:\ResonaBot\.venv\lib\site-packages\YetAnotherPicSearch\__main__.py", line 261, in fetch_image
    async with fail_with_msg(
  File "C:\Python310\lib\contextlib.py", line 217, in __aexit__
    await self.gen.athrow(typ, value, traceback)
> File "F:\ResonaBot\.venv\lib\site-packages\YetAnotherPicSearch\__main__.py", line 150, in fail_with_msg
    yield
  File "F:\ResonaBot\.venv\lib\site-packages\YetAnotherPicSearch\__main__.py", line 265, in fetch_image
    return await get_image_from_seg(seg)
  File "F:\ResonaBot\.venv\lib\site-packages\YetAnotherPicSearch\utils.py", line 89, in get_image_from_seg
    if file := await image_fetch(
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot_plugin_alconna\uniseg\tools.py", line 44, in image_fetch
    resp = await bot.adapter.request(req)
  File "F:\ResonaBot\.venv\lib\site-packages\nonebot\internal\adapter\adapter.py", line 91, in request
    raise TypeError("Current driver does not support http client")
TypeError: Current driver does not support http client
@In-dor In-dor added the bug Something isn't working label Aug 10, 2024
@lgc2333
Copy link
Member

lgc2333 commented Aug 10, 2024

env设置下方内容之后

DRIVER=~fastapi+~httpx+~websockets

使用下方命令安装各驱动器依赖即可

pip install nonebot2[fastapi,httpx,websockets]

其中 httpx 驱动器是提供 HTTPClient 的,你也可以只加上这一个


原因见 nonebot/nonebot2#2435 adapter.py 章节中 第 2 条:

适配器的网络请求或 ws 连接应通过驱动器的 Request 进行。

Alconna 的 image_fetch 函数获取各平台图片时使用了 HTTP 驱动器,因为这是关联于各适配器的操作

@lgc2333 lgc2333 added question Further information is requested wontfix This will not be worked on and removed bug Something isn't working wontfix This will not be worked on labels Aug 10, 2024
@In-dor
Copy link
Author

In-dor commented Aug 10, 2024

非常感谢,顺便解决了我这边表情包制作不能用自己发图的问题。

@KiriSuoh
Copy link

KiriSuoh commented Jan 2, 2025

感谢答疑!我这边在.env.prod中设置、以及安装依赖pip install nonebot2[fastapi,httpx,websockets]后,仍然会在搜图时立刻发一次报错,不过搜图功能正常有结果。

17389828EFFE1E3BE8CD9112DA38C3B2

如何复现:
进行任意搜图

各版本:
YetAnotherPicSearch 2.0.4
PicImageSearch 3.11.3
napcat 4.2.42
nonebot 2.4.1
Python 3.12.4
Windows 10 21H2

Package Version


aiohappyeyeballs 2.4.4
aiohttp 3.11.11
aiosignal 1.3.2
alembic 1.14.0
annotated-types 0.7.0
anyio 4.4.0
argcomplete 3.4.0
attrs 24.3.0
certifi 2024.8.30
click 8.1.7
colorama 0.4.6
cssselect 1.2.0
exceptiongroup 1.2.2
fastapi 0.115.6
frozenlist 1.5.0
greenlet 3.1.1
h11 0.14.0
h2 4.1.0
hpack 4.0.0
httpcore 1.0.5
httptools 0.6.4
httpx 0.28.1
hyperframe 6.0.1
idna 3.10
loguru 0.7.3
lxml 5.3.0
Mako 1.3.8
MarkupSafe 3.0.2
multidict 6.1.0
nonebot_session_to_uninfo 0.0.2
nonebot2 2.4.1
packaging 24.1
PicImageSearch 3.11.3
Pillow 10.0.0
pip 24.3.1
pipx 1.6.0
platformdirs 4.2.2
playwright 1.49.1
propcache 0.2.1
pydantic 2.10.4
pydantic_core 2.27.2
pyee 12.0.0
pygtrie 2.5.0
pyquery 2.0.1
python-dotenv 1.0.1
PyYAML 6.0.2
setuptools 75.6.0
sniffio 1.3.1
SQLAlchemy 2.0.36
starlette 0.41.3
StrEnum 0.4.15
typing_extensions 4.12.2
userpath 1.9.2
uvicorn 0.34.0
watchfiles 1.0.3
websockets 14.1
win32_setctime 1.2.0
yarl 1.18.3

报错代码:

01-02 13:10:31 [ERROR] YetAnotherPicSearch | Error occurred
Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\__init__.py", line 337, in run
    get_driver().run(*args, **kwargs)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\drivers\fastapi.py", line 187, in run
    uvicorn.run(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\uvicorn\main.py", line 577, in run
    server.run()
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\uvicorn\server.py", line 65, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 194, in run
    return runner.run(main)
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 674, in run_until_complete
    self.run_forever()
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\asyncio\windows_events.py", line 322, in run_forever
    super().run_forever()
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 641, in run_forever
    self._run_once()
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\asyncio\base_events.py", line 1987, in _run_once
    handle._run()
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\asyncio\events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\utils.py", line 254, in run_coro_with_shield
    return await coro
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\message.py", line 506, in check_and_run_matcher
    await _run_matcher(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\message.py", line 458, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 926, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\internal\matcher\matcher.py", line 863, in simple_run
    await handler(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\dependencies\__init__.py", line 113, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\YetAnotherPicSearch\__main__.py", line 319, in search_handler
    await handle_single_image(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\YetAnotherPicSearch\__main__.py", line 283, in handle_single_image
    if (not file) and (not (file := await fetch_image(seg))):
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\YetAnotherPicSearch\__main__.py", line 263, in fetch_image
    async with fail_with_msg(
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 231, in __aexit__
    await self.gen.athrow(value)
> File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\YetAnotherPicSearch\__main__.py", line 151, in fail_with_msg
    yield
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\YetAnotherPicSearch\__main__.py", line 267, in fetch_image
    return await get_image_from_seg(seg)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\YetAnotherPicSearch\utils.py", line 78, in get_image_from_seg
    if file := await image_fetch(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot_plugin_alconna\uniseg\tools.py", line 48, in image_fetch
    resp = await bot.adapter.request(req)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\internal\adapter\adapter.py", line 92, in request
    return await self.driver.request(setup)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\drivers\httpx.py", line 134, in request
    return await session.request(setup)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\nonebot\drivers\httpx.py", line 78, in request
    response = await self.client.request(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpx\_client.py", line 1540, in request
    return await self.send(request, auth=auth, follow_redirects=follow_redirects)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpx\_client.py", line 1629, in send
    response = await self._send_handling_auth(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpx\_client.py", line 1657, in _send_handling_auth
    response = await self._send_handling_redirects(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpx\_client.py", line 1694, in _send_handling_redirects
    response = await self._send_single_request(request)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpx\_client.py", line 1730, in _send_single_request
    response = await transport.handle_async_request(request)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpx\_transports\default.py", line 394, in handle_async_request
    resp = await self._pool.handle_async_request(req)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 216, in handle_async_request
    raise exc from None
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpcore\_async\connection_pool.py", line 196, in handle_async_request
    response = await connection.handle_async_request(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpcore\_async\http_proxy.py", line 317, in handle_async_request
    stream = await stream.start_tls(**kwargs)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpcore\_async\http11.py", line 383, in start_tls
    return await self._stream.start_tls(ssl_context, server_hostname, timeout)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpcore\_backends\anyio.py", line 80, in start_tls
    raise exc
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\httpcore\_backends\anyio.py", line 71, in start_tls
    ssl_stream = await anyio.streams.tls.TLSStream.wrap(
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\anyio\streams\tls.py", line 132, in wrap
    await wrapper._call_sslobject_method(ssl_object.do_handshake)
  File "F:\nonebot\FF_Bot\.venv\Lib\site-packages\anyio\streams\tls.py", line 140, in _call_sslobject_method
    result = func(*args)
  File "C:\Users\Cyber\AppData\Local\Programs\Python\Python312\Lib\ssl.py", line 917, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants