cpuopt / nonebot_plugin_imgexploration

Google、Yandx和基于PicImageSearch的saucenao、ascii2d搜图
MIT License
30 stars 0 forks source link

UnboundLocalError: local variable 'result_li' referenced before assignment #7

Closed RokasUrbelis closed 1 year ago

RokasUrbelis commented 1 year ago

image 02-12 02:58:47 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_imgexploration) failed. Traceback (most recent call last): File "", line 17, in File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/init.py", line 273, in run get_driver().run(*args, **kwargs) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 187, in run uvicorn.run( File "/opt/first/.venv/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run server.run() File "/opt/first/.venv/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/message.py", line 141, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/message.py", line 187, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 732, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 707, in simple_run await handler( File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot_plugin_imgexploration/init.py", line 49, in get_pic await search.doSearch() File "/opt/first/.venv/lib/python3.10/site-packages/nonebot_plugin_imgexploration/imgexploration.py", line 411, in doSearch self.__result_info = (await task_saucenao) + (await task_ascii2d) + (await task_google) + (await task_yandex) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot_plugin_imgexploration/imgexploration.py", line 355, in __ascii2d_build_result logger.success(f"ascii2d result:{len(result_li)}") UnboundLocalError: local variable 'result_li' referenced before assignment 02-12 02:58:47 [ERROR] nonebot_plugin_imgexploration | [Errno -2] Name or service not known 02-12 02:58:47 [SUCCESS] nonebot_plugin_imgexploration | google result:0 02-12 02:58:47 [ERROR] nonebot_plugin_imgexploration | [Errno -2] Name or service not known

第二个问题,proxy变量应该不是必填项吧,我本地走openwrt,不需要在系统上单独设置proxy

cpuopt commented 1 year ago

那肯定是不填不行

cpuopt commented 1 year ago

修改了一个无代理的版本 https://github.com/cpuopt/nonebot_plugin_imgexploration/tree/no-proxies/nonebot_plugin_imgexploration 替换这两个py文件就可以了

RokasUrbelis commented 1 year ago

替换两个文件后,代理问题解决了,这个报错仍然还在: image 02-13 03:03:51 [ERROR] nonebot | Running Matcher(type='message', module=nonebot_plugin_imgexploration) failed. Traceback (most recent call last): File "", line 17, in File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/init.py", line 273, in run get_driver().run(*args, **kwargs) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/drivers/fastapi.py", line 187, in run uvicorn.run( File "/opt/first/.venv/lib/python3.10/site-packages/uvicorn/main.py", line 569, in run server.run() File "/opt/first/.venv/lib/python3.10/site-packages/uvicorn/server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run return loop.run_until_complete(main) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/message.py", line 141, in _check_matcher await _run_matcher(Matcher, bot, event, state, stack, dependency_cache)

File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/message.py", line 187, in _run_matcher await matcher.run(bot, event, state, stack, dependency_cache) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 732, in run await self.simple_run(bot, event, state, stack, dependency_cache) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/internal/matcher/matcher.py", line 707, in simple_run await handler( File "/opt/first/.venv/lib/python3.10/site-packages/nonebot/dependencies/init.py", line 108, in call return await cast(Callable[..., Awaitable[R]], self.call)(**values) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot_plugin_imgexploration/init.py", line 48, in get_pic await search.doSearch() File "/opt/first/.venv/lib/python3.10/site-packages/nonebot_plugin_imgexploration/imgexploration.py", line 409, in doSearch self.__result_info = (await task_saucenao) + (await task_ascii2d) + (await task_google) + (await task_yandex) File "/opt/first/.venv/lib/python3.10/site-packages/nonebot_plugin_imgexploration/imgexploration.py", line 353, in __ascii2d_build_result logger.success(f"ascii2d result:{len(result_li)}") UnboundLocalError: local variable 'result_li' referenced before assignment

RokasUrbelis commented 1 year ago

而且每次都出现几个ERROR: image

Drawing 搜出来的东西差距太大 image image

cpuopt commented 1 year ago

ERROR和那个报错是网络问题,梯子共用的人太多,撞了网站的速率限制 比如我这个梯子是没问题的 img img saucenao和ascii2d是用来搜动漫插画的,识别不了其他图片

cpuopt commented 1 year ago

刚刚更新了0.2.4 解决了result_li未定义问题 (logger的error是网络问题,只能换节点或换梯子解决) 不使用代理,不写配置项proxy_port或留空就可以,用pip更新或nb plugin重装插件就行

RokasUrbelis commented 1 year ago

✅已解决。