nonebot / nonebot2

跨平台 Python 异步聊天机器人框架 / Asynchronous multi-platform chatbot framework written in Python
https://nonebot.dev
MIT License
5.84k stars 551 forks source link

nb初始化出错 #1427

Closed homuraLan closed 1 year ago

homuraLan commented 1 year ago

系统Windows 11

D:\NoneBot2>nb init
[?] Project Name:  homura
[?] Where to store the plugin?  2) In a "src" folder
[?] Load NoneBot Builtin Plugin?  Yes
[?] Which adapter(s) would you like to use?  (<up>, <down> to move, <space> to select, <a> to toggle, <i> to invert)
Traceback (most recent call last):
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\cache.py", line 34, in get
    return self._data[key]
KeyError: 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\conda_data\envs\Python3.8.15\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\conda_data\envs\Python3.8.15\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\conda_data\envs\Python3.8.15\Scripts\nb.exe\__main__.py", line 7, in <module>
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nb_cli\__init__.py", line 30, in init
    create_project()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nb_cli\handlers.py", line 105, in create_project
    answers2 = prompt(question2, qmark="[?]", style=list_style)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\PyInquirer\prompt.py", line 69, in prompt
    answer = run_application(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\shortcuts.py", line 625, in run_application
    result = cli.run()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\interface.py", line 413, in run
    self._redraw()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\interface.py", line 358, in _redraw
    self.renderer.render(self, self.layout, is_done=self.is_done)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\renderer.py", line 424, in render
    layout.write_to_screen(cli, screen, mouse_handlers, WritePosition(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\containers.py", line 142, in write_to_screen
    sizes = self._divide_heigths(cli, write_position)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\containers.py", line 177, in _divide_heigths
    dimensions = [get_dimension_for_child(c, index) for index, c in enumerate(self.children)]
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\containers.py", line 177, in <listcomp>
    dimensions = [get_dimension_for_child(c, index) for index, c in enumerate(self.children)]
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\containers.py", line 175, in get_dimension_for_child
    return c.preferred_height(cli, write_position.width, write_position.extended_height)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\containers.py", line 1652, in preferred_height
    return self.content.preferred_height(cli, width, max_available_height)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\containers.py", line 999, in preferred_height
    preferred=self.content.preferred_height(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\controls.py", line 254, in preferred_height
    content = self.create_content(cli, width, None)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\controls.py", line 259, in create_content
    tokens_with_mouse_handlers = self._get_tokens_cached(cli)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\controls.py", line 238, in _get_tokens_cached
    return self._token_cache.get(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\cache.py", line 37, in get
    value = getter_func()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\layout\controls.py", line 239, in <lambda>
    cli.render_counter, lambda: self.get_tokens(cli))
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\PyInquirer\prompts\checkbox.py", line 99, in _get_choice_tokens
    tokens.pop()  # Remove last newline.
IndexError: pop from empty list
homuraLan commented 1 year ago

在python3.10中出现了 ImportError: cannot import name ‘Mapping’ from ‘collections’ (F:\lib\collectionsinit.py) 问题 提醒修复

homuraLan commented 1 year ago

在我修改文件强行忽略掉这个错误之后又出现了以下错误:

D:\NoneBot2>nb init
[?] Project Name:  homura
[?] Where to store the plugin?  2) In a "src" folder
[?] Load NoneBot Builtin Plugin?  Yes
[?] Which adapter(s) would you like to use?  (<up>, <down> to move, <space> to select, <a> to toggle, <i> to invert)
Traceback (most recent call last):
  File "D:\conda_data\envs\Python3.8.15\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "D:\conda_data\envs\Python3.8.15\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\conda_data\envs\Python3.8.15\Scripts\nb.exe\__main__.py", line 7, in <module>
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nb_cli\__init__.py", line 30, in init
    create_project()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\nb_cli\handlers.py", line 105, in create_project
    answers2 = prompt(question2, qmark="[?]", style=list_style)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\PyInquirer\prompt.py", line 69, in prompt
    answer = run_application(
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\shortcuts.py", line 625, in run_application
    result = cli.run()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\interface.py", line 415, in run
    self.eventloop.run(self.input, self.create_eventloop_callbacks())
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\eventloop\win32.py", line 81, in run
    callbacks.feed_key(k)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\interface.py", line 1043, in feed_key
    cli.input_processor.process_keys()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\key_binding\input_processor.py", line 219, in process_keys
    self._process_coroutine.send(key_press)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\key_binding\input_processor.py", line 176, in _process
    self._call_handler(matches[-1], key_sequence=buffer[:])
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\key_binding\input_processor.py", line 247, in _call_handler
    handler.call(event)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\prompt_toolkit\key_binding\registry.py", line 61, in call
    return self.handler(event)
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\PyInquirer\prompts\checkbox.py", line 210, in move_cursor_down
    _next()
  File "D:\conda_data\envs\Python3.8.15\lib\site-packages\PyInquirer\prompts\checkbox.py", line 209, in _next
    ic.pointer_index = ((ic.pointer_index + 1) % ic.line_count)
ZeroDivisionError: integer division or modulo by zero

我看到别人 Which adapter(s) would you like to use? 有这些选项,我没有,还会报错 image

yanyongyu commented 1 year ago

请升级你的nbcli,最新版本是0.6.7

homuraLan commented 1 year ago

请升级你的nbcli,最新版本是0.6.7

我使用 pip install nb-cli直接安装,环境是新的python没装过别的,换成新的要怎么操作

homuraLan commented 1 year ago

pip install nb-cli

因为我得到了不太好处理的新错误:

pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pyinquirer 1.0.3 requires prompt-toolkit==1.0.14, but you have prompt-toolkit 3.0.33 which is incompatible.
poetry 1.2.2 requires tomlkit!=0.11.2,!=0.11.3,<1.0.0,>=0.11.1, but you have tomlkit 0.10.2 which is incompatible
yanyongyu commented 1 year ago

请不要使用过时的镜像源,删除或更换正常的镜像源后使用pip install --upgrade nb-cli升级

homuraLan commented 1 year ago

请不要使用过时的镜像源,删除或更换正常的镜像源后使用pip install --upgrade nb-cli升级

清华源

yanyongyu commented 1 year ago

请不要使用过时的镜像源,删除或更换正常的镜像源后使用pip install --upgrade nb-cli升级

清华源

说的就是清华源,版本落后多少了

homuraLan commented 1 year ago

请不要使用过时的镜像源,删除或更换正常的镜像源后使用pip install --upgrade nb-cli升级

清华源

说的就是清华源,版本落后多少了

那用啥

yanyongyu commented 1 year ago

那用啥

多的是啊,阿里腾讯华为中科大交大等等

homuraLan commented 1 year ago

那用啥

多的是啊,阿里腾讯华为中科大交大等等

已实测,华为,阿里,中科大源均有类似错误,之前我忽视掉了这些错误,现在导致某些插件无法正常导入

homuraLan commented 1 year ago

那用啥

多的是啊,阿里腾讯华为中科大交大等等

我使用Anaconda创建虚拟python环境

homuraLan commented 1 year ago

例如

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pyinquirer 1.0.3 requires prompt-toolkit==1.0.14, but you have prompt-toolkit 3.0.33 which is incompatible.
poetry 1.2.2 requires tomlkit!=0.11.2,!=0.11.3,<1.0.0,>=0.11.1, but you have tomlkit 0.9.2 which is incompatible.

当我按照要求安装这些包对应版本以后又会出现

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
nonebot2 2.0.0b2 requires tomlkit<0.10.0,>=0.9.0, but you have tomlkit 0.11.1 which is incompatible.
nb-cli 0.6.6 requires prompt-toolkit<4.0.0,>=3.0.19, but you have prompt-toolkit 1.0.14 which is incompatible.
nb-cli 0.6.6 requires tomlkit<0.10.0,>=0.9.0, but you have tomlkit 0.11.1 which is incompatible.

以上错误最后在华为源中复现

yanyongyu commented 1 year ago

升级你的nb2

homuraLan commented 1 year ago

升级你的nb2

nb-cli 0.6.7 requires tomlkit<0.11.0,>=0.10.0, but you have tomlkit 0.11.6 which is incompatible. 乐 我甚至都找不到这个tomlkit版本

homuraLan commented 1 year ago

装了个prompt_toolkit-3.0.36 我的建议是你们教程写清楚 ,这玩意儿一般源根本扒不下来,没这东西直接报错

yanyongyu commented 1 year ago

乐,装包还能依赖装不全的

yanyongyu commented 1 year ago

有问题请去 https://discussions.nonebot.dev 这里是bug反馈平台