Quan666 / ELF_RSS

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

导入插件错误ImportError: cannot import name 'BaseConfig' from 'nonebot.config' (D:\yunzai\nonebot\qq2\.venv\lib\site-packages\nonebot\config.py) #484

Closed lintonxue00 closed 6 months ago

lintonxue00 commented 7 months ago

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

02-16 08:11:58 [ERROR] nonebot | Failed to import "ELF_RSS2" Traceback (most recent call last): File "", line 14, in File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\nonebot\plugin\load.py", line 130, in load_from_toml return load_all_plugins(plugins, plugin_dirs) File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\nonebot\plugin\load.py", line 64, in load_all_plugins return manager.load_all_plugins() File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\nonebot\plugin\manager.py", line 176, in load_all_plugins return set( File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\nonebot\plugin\manager.py", line 177, in filter(None, (self.load_plugin(name) for name in self.available_plugins))

File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\nonebot\plugin\manager.py", line 142, in load_plugin module = importlib.import_module(name) File "C:\Users\USER451533\AppData\Local\Programs\Python\Python310\lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\nonebot\plugin\manager.py", line 242, in exec_module super().exec_module(module) File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\ELF_RSS2__init__.py", line 11, in from . import command File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\ELF_RSS2\command\init__.py", line 1, in from . import ( File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\ELF_RSS2\command\add_cookies.py", line 9, in from .. import my_trigger as tr File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\ELF_RSS2\my_trigger.py", line 11, in from . import rss_parsing File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\ELF_RSS2\rss_parsing.py", line 11, in from .config import DATA_PATH, config File "D:\yunzai\nonebot\qq2.venv\lib\site-packages\ELF_RSS2\config.py", line 5, in from nonebot.config import BaseConfig ImportError: cannot import name 'BaseConfig' from 'nonebot.config' (D:\yunzai\nonebot\qq2.venv\lib\site-packages\nonebot\config.py)

列出安装的 Python 包

No response

如何复现

在nonebot使用nb plugin install ELF-RSS然后启动报错,报错大意好像是加载插件错误 image

期望行为

正常启动

实际行为

加载错误

lintonxue00 commented 7 months ago

image

Quan666 commented 7 months ago

你的依赖都是什么版本

Hana-Akira commented 7 months ago

我也出现同样问题,但我今天的操作就是装了其他的插件和nonebot更新到了2.2.0

Package Version aiofiles 23.2.1 aiohttp 3.9.1 aiosignal 1.3.1 anyio 3.7.1 APScheduler 3.10.4 arclet-alconna 1.7.42 arclet-alconna-tools 0.6.11 argcomplete 3.2.2 arrow 1.3.0 async-timeout 4.0.3 asyncio 3.4.3 attrs 23.1.0 bbcode 1.1.0 beautifulsoup4 4.12.2 binaryornot 0.4.4 Brotli 1.1.0 bs4 0.0.2 cachetools 5.3.2 cashews 6.4.0 certifi 2023.11.17 cfscrape 2.1.1 chardet 5.2.0 charset-normalizer 3.3.2 click 8.1.7 colorama 0.4.6 cookiecutter 2.5.0 cssselect 1.2.0 deep-translator 1.11.4 distlib 0.3.8 ELF_RSS 2.6.21 emoji 2.8.0 exceptiongroup 1.2.0 fastapi 0.104.1 feedparser 6.0.10 filelock 3.13.1 fleep 1.0.1 frozenlist 1.4.0 greenlet 3.0.1 h11 0.14.0 h2 4.1.0 hpack 4.0.0 httpcore 0.18.0 httptools 0.6.1 httpx 0.25.0 hyperframe 6.0.1 idna 3.6 ImageHash 4.3.1 Jinja2 3.1.3 loguru 0.7.2 lxml 4.9.3 magneturi 1.3 Markdown 3.5.2 markdown-it-py 3.0.0 MarkupSafe 2.1.3 mdurl 0.1.2 msgpack 1.0.7 multidict 6.0.4 nb-cli 1.3.1 nepattern 0.5.15 nonebot-adapter-kaiheila 0.3.1 nonebot-adapter-onebot 2.4.1 nonebot-adapter-qq 1.4.1 nonebot-adapter-telegram 0.1.0b16 nonebot-plugin-alconna 0.36.0 nonebot-plugin-analysis-bilibili 2.6.8 nonebot-plugin-apscheduler 0.3.0 nonebot-plugin-BitTorrent 0.0.18 nonebot-plugin-capoo 0.1.4 nonebot-plugin-emojimix 0.3.1 nonebot-plugin-guild-patch 0.2.3 nonebot-plugin-htmlrender 0.3.0 nonebot_plugin_manager 0.5.16 nonebot-plugin-picsearcher 0.1.10 nonebot-plugin-picstatus 1.0.2 nonebot-plugin-questionmark 0.4.1 nonebot-plugin-send-anything-anywhere 0.3.2 nonebot-plugin-sendmsg-by-bots 0.0.5 nonebot-plugin-simplemusic 0.1.7 nonebot-plugin-steam-game-status 0.1.5 nonebot-plugin-today-in-history 0.1.3 nonebot-plugin-twitter 0.2.3 nonebot_plugin_userinfo 0.1.3 nonebot2 2.2.0 noneprompt 0.1.9 numpy 1.26.2 packaging 23.2 pikpakapi 0.1.3 Pillow 10.0.0 pip 24.0 pipx 1.4.3 platformdirs 4.2.0 playwright 1.40.0 prompt-toolkit 3.0.43 psutil 5.9.8 py-cpuinfo 9.0.0 pydantic 1.10.14 pyee 11.0.1 pyfiglet 1.0.2 Pygments 2.17.2 pygtrie 2.5.0 pymdown-extensions 10.7 pyquery 2.0.0 python-dateutil 2.8.2 python-dotenv 1.0.0 python-markdown-math 0.8 python-qbittorrent 0.4.3 python-slugify 8.0.4 pytz 2023.3.post1 PyWavelets 1.5.0 PyYAML 6.0.1 requests 2.31.0 rfc3986 1.5.0 rich 13.7.0 scipy 1.11.4 setuptools 65.6.3 sgmllib3k 1.0.0 six 1.16.0 sniffio 1.3.0 soupsieve 2.5 SQLAlchemy 2.0.27 starlette 0.27.0 StrEnum 0.4.15 tarina 0.4.2 tenacity 8.2.3 text-unidecode 1.3 tinydb 4.8.0 tomli 2.0.1 tomlkit 0.12.3 types-python-dateutil 2.8.19.14 typing_extensions 4.9.0 tzdata 2023.3 tzlocal 5.2 urllib3 1.26.16 userpath 1.9.1 uvicorn 0.24.0.post1 virtualenv 20.25.0 watchfiles 0.21.0 wcwidth 0.2.13 websockets 12.0 wheel 0.38.4 win32-setctime 1.1.0 yarl 1.9.4

Quan666 commented 7 months ago

版本不对,这个项目用到的版本比较旧了。 要么用虚拟环境装,要么谁来适配下新版本

Hana-Akira commented 7 months ago

确实,刚测试了下是nonebot的问题,最新版本不支持。得回退上个版本了

NekoAria commented 6 months ago

这样做应该就能正常用了吧:

  1. 去除 pydantic AnyHttpUrl (可能不需要):

    https://github.com/Quan666/ELF_RSS/blob/c72c7ae63f76079fd2f90a5f1752b3472b0528b5/src/plugins/ELF_RSS2/config.py#L7

    https://github.com/Quan666/ELF_RSS/blob/c72c7ae63f76079fd2f90a5f1752b3472b0528b5/src/plugins/ELF_RSS2/config.py#L21

  2. 修改 pydantic 的依赖要求:

    https://github.com/Quan666/ELF_RSS/blob/c72c7ae63f76079fd2f90a5f1752b3472b0528b5/pyproject.toml#L33

    https://github.com/Quan666/ELF_RSS/blob/c72c7ae63f76079fd2f90a5f1752b3472b0528b5/requirements.txt#L18

    分别改为 pydantic = ">=1.10.0,<3.0.0,!=2.5.0,!=2.5.1"pydantic>=1.10.0,<3.0.0,!=2.5.0,!=2.5.1

  3. 发布新版本

HeliumOctahelide commented 6 months ago

ELF_RSS2\config.py

from nonebot.config import BaseConfig

一行的BaseConfig改成Config就可以了。

Quan666 commented 6 months ago

ELF_RSS2\config.py

from nonebot.config import BaseConfig

一行的BaseConfig改成Config就可以了。

有用的话可以提交个pr,我合并上去

HeliumOctahelide commented 6 months ago

ELF_RSS2\config.py

from nonebot.config import BaseConfig

一行的BaseConfig改成Config就可以了。

有用的话可以提交个pr,我合并上去

应该可以了,我用了两天能正常运行