Quan666 / ELF_RSS

QQ机器人 RSS订阅 插件,订阅源建议选择 RSSHub
https://myelf.club/archives/221
GNU General Public License v3.0
563 stars 57 forks source link

NoneBot初始化错误的问题 #45

Closed kkjzio closed 3 years ago

kkjzio commented 3 years ago
[ELF_RSS-2.1.7]# nb run
03-08 11:37:50 [INFO] nonebot | NoneBot is initializing...
Traceback (most recent call last):
  File "/usr/local/python3/bin/nb", line 8, in <module>
    sys.exit(main())
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/nb_cli/__init__.py", line 46, in run
    run_bot(file, app)
  File "/usr/local/python3/lib/python3.8/site-packages/nb_cli/handlers.py", line 44, in run_bot
    module = importlib.import_module(module_name)
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./bot.py", line 16, in <module>
    nonebot.init()
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/__init__.py", line 175, in init
    env = Env()
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/config.py", line 38, in __init__
    __pydantic_self__).__init__(**__pydantic_self__._build_values(
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/config.py", line 53, in _build_values
    return deep_update(self._build_secrets_files(_secrets_dir),
TypeError: 'NoneType' object is not callable

今天把1.3.7的版本删了,准备换2.x的版本,按照教程安装了requirement中的包,出现了不兼容,然后使用pip3 uninstall -r requirements.txt卸载后再重新使用pip3 install -r requirements.txt安装后无报错,运行run nb后出现以上错误。配置文件中linux系统已经设置为true。 环境配置为:

Quan666 commented 3 years ago

不要从release下,最新版还没发release 这个是pydantic版本不兼容导致 最新版已经不会有这个问题

kkjzio commented 3 years ago

首先谢谢回答,nb机器人能跑了,但是还是出现ELF_RSS2载入失败的问题

[ELF_RSS]# nb run
03-08 12:35:16 [INFO] nonebot | NoneBot is initializing...
03-08 12:35:16 [INFO] nonebot | Current Env: prod
03-08 12:35:16 [DEBUG] nonebot | Loaded Config: {'driver': 'nonebot.drivers.fastapi', 'host': IPv4Address('0.0.0.0'), 'port': 8080, 'debug': True, 'api_root': {}, 'api_timeout': 30.0, 'access_token': None, 'secret': None, 'superusers': {'253839323'}, 'nickname': {'elf', 'ELF'}, 'command_start': {'', '/'}, 'command_sep': {'.'}, 'session_expire_timeout': datetime.timedelta(seconds=120), 'baidukey': '', 'qb_web_url': 'http://127.0.0.1:8081', 'delcache': 3, 'close_pixiv_cat': False, 'baiduid': '', 'islinux': True, 'usebaidu': False, 'environment': 'prod', 'down_status_msg_group': [], 'rsshub_backup': [], 'zip_size': 3072, 'rss_proxy': '127.0.0.1:7890', 'limt': 50, 'version': 'v2.1.7', 'showblockword': True, 'blockquote': True, 'rsshub': 'http://rss.shab.fun', 'is_open_auto_down_torrent': False, 'blockword': ['互动抽奖', '微博抽奖平台'], 'down_status_msg_date': 10}
03-08 12:35:16 [DEBUG] nonebot | Succeeded to load adapter "cqhttp"
03-08 12:35:16 [INFO] nonebot | Succeeded to import "nonebot.plugins.echo"
03-08 12:35:16 [INFO] nonebot | Succeeded to import "nonebot_plugin_apscheduler"
03-08 12:35:16 [INFO] nonebot | Succeeded to import "ELF_URL"
03-08 12:35:16 [ERROR] nonebot | Failed to import "ELF_RSS2"
Traceback (most recent call last):
  File "/usr/local/python3/bin/nb", line 8, in <module>
    sys.exit(main())
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/python3/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/nb_cli/commands/main.py", line 26, in run
    run_bot(file, app)
  File "/usr/local/python3/lib/python3.8/site-packages/nb_cli/handlers/deploy.py", line 17, in run_bot
    module = importlib.import_module(module_name)
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./bot.py", line 23, in <module>
    nonebot.load_plugins("src/plugins")
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/plugin/__init__.py", line 1013, in load_plugins
    result = context.run(_load_plugin, manager, plugin_name)
> File "/usr/local/python3/lib/python3.8/site-packages/nonebot/plugin/__init__.py", line 960, in _load_plugin
    module = manager.load_plugin(plugin_name)
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/plugin/manager.py", line 146, in load_plugin
    return importlib.import_module(f"{self.namespace}.{name}")
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "src/plugins/ELF_RSS2/__init__.py", line 1, in <module>
    from . import add_cookies, add_dy, change_dy, del_dy, show_all, show_dy, start  # noqa
  File "src/plugins/ELF_RSS2/add_cookies.py", line 7, in <module>
    from .RSS import rss_class
  File "src/plugins/ELF_RSS2/RSS/rss_class.py", line 10, in <module>
    from ..config import config
  File "src/plugins/ELF_RSS2/config.py", line 49, in <module>
    config = ELFConfig(get_driver().config.dict())
  File "pydantic/env_settings.py", line 37, in pydantic.env_settings.BaseSettings.__init__
    **__pydantic_self__._build_values(
  File "pydantic/env_settings.py", line 63, in pydantic.env_settings.BaseSettings._build_values
    return deep_update(*reversed([source(self) for source in sources]))
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/config.py", line 45, in __call__
    env_path = Path(env_file)
  File "/usr/local/python3/lib/python3.8/pathlib.py", line 1038, in __new__
    self = cls._from_parts(args, init=False)
  File "/usr/local/python3/lib/python3.8/pathlib.py", line 679, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/usr/local/python3/lib/python3.8/pathlib.py", line 663, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not dict
03-08 12:35:16 [INFO] nonebot | Running NoneBot...
03-08 12:35:16 [DEBUG] nonebot | Loaded adapters: cqhttp
03-08 12:35:16 [INFO] uvicorn | Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
03-08 12:35:16 [INFO] uvicorn | Started reloader process [15145] using watchgod
03-08 12:35:18 [INFO] nonebot | NoneBot is initializing...
03-08 12:35:18 [INFO] nonebot | Current Env: prod
03-08 12:35:18 [DEBUG] nonebot | Loaded Config: {'driver': 'nonebot.drivers.fastapi', 'host': IPv4Address('0.0.0.0'), 'port': 8080, 'debug': True, 'api_root': {}, 'api_timeout': 30.0, 'access_token': None, 'secret': None, 'superusers': {'253839323'}, 'nickname': {'elf', 'ELF'}, 'command_start': {'', '/'}, 'command_sep': {'.'}, 'session_expire_timeout': datetime.timedelta(seconds=120), 'delcache': 3, 'is_open_auto_down_torrent': False, 'zip_size': 3072, 'showblockword': True, 'rsshub_backup': [], 'qb_web_url': 'http://127.0.0.1:8081', 'blockword': ['互动抽奖', '微博抽奖平台'], 'down_status_msg_date': 10, 'rsshub': 'http://rss.shab.fun', 'baidukey': '', 'islinux': True, 'rss_proxy': '127.0.0.1:7890', 'close_pixiv_cat': False, 'limt': 50, 'usebaidu': False, 'environment': 'prod', 'blockquote': True, 'version': 'v2.1.7', 'down_status_msg_group': [], 'baiduid': ''}
03-08 12:35:18 [DEBUG] nonebot | Succeeded to load adapter "cqhttp"
03-08 12:35:18 [INFO] nonebot | Succeeded to import "nonebot.plugins.echo"
03-08 12:35:18 [INFO] nonebot | Succeeded to import "nonebot_plugin_apscheduler"
03-08 12:35:18 [ERROR] nonebot | Failed to import "ELF_RSS2"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/python3/lib/python3.8/multiprocessing/spawn.py", line 116, in spawn_main
    exitcode = _main(fd, parent_sentinel)
  File "/usr/local/python3/lib/python3.8/multiprocessing/spawn.py", line 129, in _main
    return self._bootstrap(parent_sentinel)
  File "/usr/local/python3/lib/python3.8/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/usr/local/python3/lib/python3.8/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/python3/lib/python3.8/site-packages/uvicorn/subprocess.py", line 61, in subprocess_started
    target(sockets=sockets)
  File "/usr/local/python3/lib/python3.8/site-packages/uvicorn/server.py", line 49, in run
    loop.run_until_complete(self.serve(sockets=sockets))
  File "/usr/local/python3/lib/python3.8/site-packages/uvicorn/server.py", line 56, in serve
    config.load()
  File "/usr/local/python3/lib/python3.8/site-packages/uvicorn/config.py", line 308, in load
    self.loaded_app = import_from_string(self.app)
  File "/usr/local/python3/lib/python3.8/site-packages/uvicorn/importer.py", line 20, in import_from_string
    module = importlib.import_module(module_str)
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "./bot.py", line 23, in <module>
    nonebot.load_plugins("src/plugins")
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/plugin/__init__.py", line 1013, in load_plugins
    result = context.run(_load_plugin, manager, plugin_name)
> File "/usr/local/python3/lib/python3.8/site-packages/nonebot/plugin/__init__.py", line 960, in _load_plugin
    module = manager.load_plugin(plugin_name)
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/plugin/manager.py", line 146, in load_plugin
    return importlib.import_module(f"{self.namespace}.{name}")
  File "/usr/local/python3/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "src/plugins/ELF_RSS2/__init__.py", line 1, in <module>
    from . import add_cookies, add_dy, change_dy, del_dy, show_all, show_dy, start  # noqa
  File "src/plugins/ELF_RSS2/add_cookies.py", line 7, in <module>
    from .RSS import rss_class
  File "src/plugins/ELF_RSS2/RSS/rss_class.py", line 10, in <module>
    from ..config import config
  File "src/plugins/ELF_RSS2/config.py", line 49, in <module>
    config = ELFConfig(get_driver().config.dict())
  File "pydantic/env_settings.py", line 37, in pydantic.env_settings.BaseSettings.__init__
    **__pydantic_self__._build_values(
  File "pydantic/env_settings.py", line 63, in pydantic.env_settings.BaseSettings._build_values
    return deep_update(*reversed([source(self) for source in sources]))
  File "/usr/local/python3/lib/python3.8/site-packages/nonebot/config.py", line 45, in __call__
    env_path = Path(env_file)
  File "/usr/local/python3/lib/python3.8/pathlib.py", line 1038, in __new__
    self = cls._from_parts(args, init=False)
  File "/usr/local/python3/lib/python3.8/pathlib.py", line 679, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/usr/local/python3/lib/python3.8/pathlib.py", line 663, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not dict
03-08 12:35:18 [INFO] nonebot | Succeeded to import "ELF_URL"
03-08 12:35:18 [INFO] uvicorn | Started server process [15149]
03-08 12:35:18 [INFO] uvicorn | Waiting for application startup.
03-08 12:35:18 [INFO] nonebot_plugin_apscheduler | Scheduler Started
03-08 12:35:18 [INFO] uvicorn | Application startup complete.
03-08 12:35:20 [INFO] uvicorn | ('127.0.0.1', 60662) - "WebSocket /cqhttp/ws" [accepted]
03-08 12:35:20 [INFO] nonebot | WebSocket Connection from CQHTTP Bot 1216729051 Accepted!
Quan666 commented 3 years ago

修复了

kkjzio commented 3 years ago

谢谢大大 能正常使用了