Poetry remove fails to remove any packages?

Viewed 12902

Poetry install:

(installs dependencies)
poetry show --tree

black 20.8b1 The uncompromising code formatter.
├── appdirs *
├── click >=7.1.2
├── mypy-extensions >=0.4.3
├── pathspec >=0.6,<1
├── regex >=2020.1.8
├── toml >=0.10.1
├── typed-ast >=1.4.0
└── typing-extensions >=3.7.4

Next, poetry remove...

poetry remove black


  ValueError

  Package black not found

  at ~/proj/venv/lib/python3.9/site-packages/poetry/console/commands/remove.py:52 in handle
      48│                     requirements[key] = poetry_content[section][key]
      49│                     break
      50│
      51│             if not found:
    → 52│                 raise ValueError("Package {} not found".format(name))
      53│
      54│         for key in requirements:
      55│             del poetry_content[section][key]
      56│

This seems like it should work, and the lack of search threads on this topic indicates, to me, that something that should "just work" is failing.

Any ideas? Could it be the Mac, Poetry, the dependencies...?

python3 v3.9, on a virtual env with a brew installed python.

But, the error repeats itself on the python:3.9-buster image.

1 Answers

If black is specified as a development dependency in pyproject.toml (quite likely as it is a code formatter) the --dev (or -D for short) option should be used with poetry remove i.e:

poetry remove --dev black
Related