MinatoAquaCrews / nonebot_plugin_fortune

Fortune divination plugin for nonebot2
MIT License
114 stars 25 forks source link

插件resource配置完后bot启动不能 #73

Closed PatchouliMUQ closed 1 year ago

PatchouliMUQ commented 1 year ago
(nijika) PS C:\Users\76582\Desktop\test\nijika> nb run
使用 Python: C:\Users\76582\Desktop\test\nijika\.venv\Scripts\python.exe
05-08 16:54:56 [SUCCESS] nonebot | NoneBot is initializing...
05-08 16:54:56 [INFO] nonebot | Current Env: prod
05-08 16:54:56 [SUCCESS] nonebot | Succeeded to load plugin "echo" from "nonebot.plugins.echo"
05-08 16:54:57 [ERROR] nonebot | Failed to import "nonebot_plugin_apscheduler"
Traceback (most recent call last):
  File "C:\Users\76582\Desktop\test\nijika\bot.py", line 14, in <module>
    nonebot.load_from_toml("pyproject.toml")
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\load.py", line 125, in load_from_toml
    return load_all_plugins(plugins, plugin_dirs)
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\load.py", line 62, in load_all_plugins
    return manager.load_all_plugins()
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 175, in load_all_plugins
    return set(
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 176, in <genexpr>
    filter(None, (self.load_plugin(name) for name in self.available_plugins))
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 141, in load_plugin
    module = importlib.import_module(name)
  File "C:\Users\76582\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_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:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 240, 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:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot_plugin_fortune\__init__.py", line 15, in <module>
    require("nonebot_plugin_apscheduler")
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\load.py", line 168, in require
    plugin = load_plugin(name)
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\load.py", line 37, in load_plugin
    return manager.load_plugin(module_path)
> File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 154, in load_plugin
    raise RuntimeError(
RuntimeError: Module nonebot_plugin_apscheduler is not loaded as a plugin! Make sure not to import it before loading.
05-08 16:54:57 [ERROR] nonebot | Failed to import "nonebot_plugin_fortune"
Traceback (most recent call last):
  File "C:\Users\76582\Desktop\test\nijika\bot.py", line 14, in <module>
    nonebot.load_from_toml("pyproject.toml")
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\load.py", line 125, in load_from_toml
    return load_all_plugins(plugins, plugin_dirs)
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\load.py", line 62, in load_all_plugins
    return manager.load_all_plugins()
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 175, in load_all_plugins
    return set(
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 176, in <genexpr>
    filter(None, (self.load_plugin(name) for name in self.available_plugins))
> File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 141, in load_plugin
    module = importlib.import_module(name)
  File "C:\Users\76582\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_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:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\manager.py", line 240, 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:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot_plugin_fortune\__init__.py", line 15, in <module>
    require("nonebot_plugin_apscheduler")
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\plugin\load.py", line 170, in require
    raise RuntimeError(f'Cannot load plugin "{name}"!')
RuntimeError: Cannot load plugin "nonebot_plugin_apscheduler"!
05-08 16:54:59 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_gocqhttp"
05-08 16:54:59 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_biliav"
05-08 16:54:59 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_analysis_bilibili"
05-08 16:54:59 [SUCCESS] nonebot | Running NoneBot...
05-08 16:55:00 [INFO] uvicorn | Started server process [10560]
05-08 16:55:00 [INFO] uvicorn | Waiting for application startup.
05-08 16:55:00 [INFO] nonebot_plugin_apscheduler | Scheduler Started
05-08 16:55:00 [ERROR] uvicorn | Traceback (most recent call last):
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\starlette\routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Users\76582\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 165, in _lifespan_manager
    await self._lifespan.startup()
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\drivers\_lifespan.py", line 35, in startup
    await self._run_lifespan_func(self._startup_funcs)
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\drivers\_lifespan.py", line 29, in _run_lifespan_func
    await cast(ASYNC_LIFESPAN_FUNC, func)()
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot_plugin_fortune\config.py", line 116, in fortune_check
    raise ResourceError("Resource Mamelon.otf is missing! Please check!")
nonebot_plugin_fortune.download.ResourceError: Resource Mamelon.otf is missing! Please check!

05-08 16:55:00 [ERROR] uvicorn | Application startup failed. Exiting.

看了一遍觉得应该时这个语句 Cannot load plugin "nonebot_plugin_apscheduler"! 的问题 包括前面的这条标红语句 Failed to import "nonebot_plugin_apscheduler"

PatchouliMUQ commented 1 year ago

.env.pord 的配置如下 FORTUNE_PATH="./data/fortune" 及以下若干主题

fortune的目录 d5978d8ce452a3b24a9ea1894a73f4a

KafCoppelia commented 1 year ago

需要安装插件 nonebot_plugin_apscheduler

PatchouliMUQ commented 1 year ago

在nb中的安装插件中按照 nonebot_plugin_apscheduler 运行并安装成功后 nb run 出现了新的问题

PS C:\Users\76582\Desktop\test\nijika> nb run
使用 Python: C:\Users\76582\Desktop\test\nijika\.venv\Scripts\python.exe
05-09 11:44:52 [SUCCESS] nonebot | NoneBot is initializing...
05-09 11:44:52 [INFO] nonebot | Current Env: prod
05-09 11:44:53 [SUCCESS] nonebot | Succeeded to load plugin "echo" from "nonebot.plugins.echo"
05-09 11:44:55 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_fortune"
05-09 11:44:55 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_apscheduler"
05-09 11:44:56 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_analysis_bilibili"
05-09 11:44:56 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_biliav"
05-09 11:44:58 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_gocqhttp"
05-09 11:44:58 [SUCCESS] nonebot | Running NoneBot...
05-09 11:44:58 [INFO] uvicorn | Started server process [21884]
05-09 11:44:58 [INFO] uvicorn | Waiting for application startup.
05-09 11:44:58 [INFO] nonebot_plugin_apscheduler | Scheduler Started
05-09 11:44:58 [ERROR] uvicorn | Traceback (most recent call last):
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\starlette\routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "C:\Users\76582\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 199, in __aenter__
    return await anext(self.gen)
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 165, in _lifespan_manager
    await self._lifespan.startup()
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\drivers\_lifespan.py", line 35, in startup
    await self._run_lifespan_func(self._startup_funcs)
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot\drivers\_lifespan.py", line 29, in _run_lifespan_func
    await cast(ASYNC_LIFESPAN_FUNC, func)()
  File "C:\Users\76582\Desktop\test\nijika\.venv\lib\site-packages\nonebot_plugin_fortune\config.py", line 116, in fortune_check
    raise ResourceError("Resource Mamelon.otf is missing! Please check!")
nonebot_plugin_fortune.download.ResourceError: Resource Mamelon.otf is missing! Please check!

05-09 11:44:58 [ERROR] uvicorn | Application startup failed. Exiting.

好像是什么东西消失了,不好意思我的代码经验比较薄弱还请大佬指正🤣🤣

PatchouliMUQ commented 1 year ago

在nb中的安装插件中按照 nonebot_plugin_apscheduler 运行并安装成功后 nb run 出现了新的问题

PS C:\Users\76582\Desktop\test\nijika> nb run 使用 Python: C:\Users\76582\Desktop\test\nijika.venv\Scripts\python.exe 05-09 11:44:52 [SUCCESS] nonebot | NoneBot is initializing... 05-09 11:44:52 [INFO] nonebot | Current Env: prod 05-09 11:44:53 [SUCCESS] nonebot | Succeeded to load plugin "echo" from "nonebot.plugins.echo" 05-09 11:44:55 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_fortune" 05-09 11:44:55 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_apscheduler" 05-09 11:44:56 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_analysis_bilibili" 05-09 11:44:56 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_biliav" 05-09 11:44:58 [SUCCESS] nonebot | Succeeded to load plugin "nonebot_plugin_gocqhttp" 05-09 11:44:58 [SUCCESS] nonebot | Running NoneBot... 05-09 11:44:58 [INFO] uvicorn | Started server process [21884] 05-09 11:44:58 [INFO] uvicorn | Waiting for application startup. 05-09 11:44:58 [INFO] nonebot_plugin_apscheduler | Scheduler Started 05-09 11:44:58 [ERROR] uvicorn | Traceback (most recent call last): File "C:\Users\76582\Desktop\test\nijika.venv\lib\site-packages\starlette\routing.py", line 677, in lifespan async with self.lifespan_context(app) as maybe_state: File "C:\Users\76582\AppData\Local\Programs\Python\Python310\lib\contextlib.py", line 199, in aenter return await anext(self.gen) File "C:\Users\76582\Desktop\test\nijika.venv\lib\site-packages\nonebot\drivers\fastapi.py", line 165, in _lifespan_manager await self._lifespan.startup() File "C:\Users\76582\Desktop\test\nijika.venv\lib\site-packages\nonebot\drivers_lifespan.py", line 35, in startup await self._run_lifespan_func(self._startup_funcs) File "C:\Users\76582\Desktop\test\nijika.venv\lib\site-packages\nonebot\drivers_lifespan.py", line 29, in _run_lifespan_func await cast(ASYNC_LIFESPAN_FUNC, func)() File "C:\Users\76582\Desktop\test\nijika.venv\lib\site-packages\nonebot_plugin_fortune\config.py", line 116, in fortune_check raise ResourceError("Resource Mamelon.otf is missing! Please check!") nonebot_plugin_fortune.download.ResourceError: Resource Mamelon.otf is missing! Please check!

05-09 11:44:58 [ERROR] uvicorn | Application startup failed. Exiting. 好像是什么东西消失了,不好意思我的代码经验比较薄弱还请大佬指正🤣🤣

劳烦大佬了!我解决了!原来是我把插件的文件夹下载下来后放错文件夹了,我放在了account下面的data里面,我试着放在上一个文件夹的data下,运行成功了,谢谢大佬