SK-415 / HarukaBot

将 B 站的动态和直播信息推送至 QQ,基于 NoneBot2 开发
https://haruka-bot.sk415.icu
GNU Affero General Public License v3.0
838 stars 105 forks source link

【错误回报】Windows Server 2012 下不支持最新版 Playwright-1.31.0 #337

Closed watagashi-uni closed 1 year ago

watagashi-uni commented 1 year ago

运行环境

Windows Server 2012

HarukaBot 版本

1.5.3.post2

go-cqhttp 版本

v1.0.0-rc3

错误描述

在新 Windows Server 2012 机器上使用 pip install haruka-bot 后出现 加载失败,Playwright 依赖不全 的报错,看官网解决方法后发现只有 linux 会有这个错误。后来查看该项目的 pyproject.toml 后发现用的 1.30 版本,pip 卸载 playwright 后使用 pip install playwright==1.30 后正常启动。

目前使用 pip install haruka-bot 是默认安装的最新的 Playwright-1.31.0

可以优化 pip 一键安装流程,强制安装 playwright 的 1.30 版本,避免新安装出错。

报错日志(如果有)

02-27 17:12:41 [INFO] haruka_bot | 检查 Playwright 依赖
02-27 17:12:42 [ERROR] nonebot | Failed to import "haruka_bot"
Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\site-packages\haruka_bot\utils\__init__.p
y", line 220, in on_startup
    asyncio.get_running_loop()
RuntimeError: no running event loop

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Python310\lib\runpy.py", line 196, in _run_module_as_ma
in
    return _run_code(code, main_globals, None,
  File "C:\Program Files\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python310\Scripts\hb.exe\__main__.py", line 7, in <modu
le>
    sys.exit(main())
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1130,
in __call__
    return self.main(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1055,
in main
    rv = self.invoke(ctx)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1657,
in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 1404,
in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Program Files\Python310\lib\site-packages\click\core.py", line 760, i
n invoke
    return __callback(*args, **kwargs)
  File "C:\Program Files\Python310\lib\site-packages\haruka_bot\cli\__init__.py"
, line 14, in run
    from .bot import run
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Program Files\Python310\lib\site-packages\haruka_bot\cli\bot.py", lin
e 16, in <module>
    nonebot.load_plugin("haruka_bot")
  File "C:\Program Files\Python310\lib\site-packages\nonebot\plugin\load.py", li
ne 34, in load_plugin
    return manager.load_plugin(module_path)
> File "C:\Program Files\Python310\lib\site-packages\nonebot\plugin\manager.py",
 line 141, in load_plugin
    module = importlib.import_module(name)
  File "C:\Program Files\Python310\lib\importlib\__init__.py", line 126, in impo
rt_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "C:\Program Files\Python310\lib\site-packages\nonebot\plugin\manager.py",
 line 233, in exec_module
    super().exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "C:\Program Files\Python310\lib\site-packages\haruka_bot\__init__.py", li
ne 11, in <module>
    on_startup()
  File "C:\Program Files\Python310\lib\site-packages\haruka_bot\utils\__init__.p
y", line 226, in on_startup
    asyncio.get_event_loop().run_until_complete(check_playwright_env())
  File "C:\Program Files\Python310\lib\asyncio\base_events.py", line 649, in run
_until_complete
    return future.result()
  File "C:\Program Files\Python310\lib\site-packages\haruka_bot\utils\browser.py
", line 195, in check_playwright_env
    raise ImportError(
ImportError: 加载失败,Playwright 依赖不全,解决方法:https://haruka-bot.sk415.i
cu/faq.html#playwright-依赖不全
SK-415 commented 1 year ago

新版 Chromium 抛弃了 Windows Server 2012 及以下支持,请使用 Windows Server 2016+。

也不建议通过回退 Playwright 一直守着旧版。Windows Server 2012 R2 今年十月份就要停止维护,建议升级。

watagashi-uni commented 1 year ago

了解了,所以我感觉可以在 ”Playwright 依赖不全“ 的解决方法里加上 ”新版 Chromium 已经不支持 Windows Server 2012,建议 Windows Server 2012 的机器需要自行安装 playwright 1.30 版本“ 的提示,感谢解答

QNLanYang commented 1 year ago

我的报错和你有点像,长这样: image 但我是Win11

djkcyl commented 1 year ago

hb已放弃对winserver 2012的支持,请更新系统