ModuleNotFoundError:没有名为“poetry.console”的模块

And*_*rii 10 python python-poetry

已安装poetry库,当我添加到pyproject.toml下一个设置时:

[tool.poetry-dynamic-versioning]
enable = true
vcs = "git"
style = "pep440"
Run Code Online (Sandbox Code Playgroud)

我收到错误:

Traceback (most recent call last):
  File "/home/a-kostenko/.poetry/bin/poetry", line 17, in <module>
    from poetry.console import main
  File "/home/a-kostenko/.local/lib/python3.8/site-packages/poetry_dynamic_versioning/__init__.py", line 409, in alt_import
    module = _state.original_import_func(name, globals, locals, fromlist, level)
ModuleNotFoundError: No module named 'poetry.console'
Run Code Online (Sandbox Code Playgroud)

请帮忙,出了什么问题?

Pra*_*rni 17

尝试做which\where诗歌。也许你有多个诗歌装置。请注意,现在有两个版本get-poetry.pyinstall-poetry.py 因此请确保卸载这两个版本,然后进行全新安装。

首先卸载所有内容。

curl -sSL https://install.python-poetry.org > install-poetry.py
python install-poetry.py --uninstall
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py > get-poetry.py
python get-poetry.py --uninstall
Run Code Online (Sandbox Code Playgroud)

然后使用新install-poetry.py脚本再次安装

curl -sSL https://install.python-poetry.org > install-poetry.py
python install-poetry.py
Run Code Online (Sandbox Code Playgroud)

然后确保路径是否在环境中:

$HOME/.local/bin for Unix
%APPDATA%\Python\Scripts on Windows
Run Code Online (Sandbox Code Playgroud)

最后测试

poetry --version
Run Code Online (Sandbox Code Playgroud)

  • 更新到此 - 截至目前,https://install.python-poetry.org 是 install-poetry.py 脚本的规范源。这些步骤仍然有效,但最好将 `curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py &gt; install-poetry.py` 的每个实例替换为 `curl -sSL https://install.python-poetry.org &gt; install-poetry.py` (3认同)

Hap*_*Bob 8

这是PowerShell的方式。

卸载

$ul = ("https://install.python-poetry.org",
       "https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py",
       "https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py")

$ul |% { (Invoke-WebRequest -Uri $_ -UseBasicParsing).Content | py - --uninstall }
Run Code Online (Sandbox Code Playgroud)

重新安装

$ul |% { (Invoke-WebRequest -Uri $_ -UseBasicParsing).Content | py -}
Run Code Online (Sandbox Code Playgroud)