python-poetry/poetry · error · PoetryError

Cannot install non directory dependencies in editable mode

Error message

Cannot install non directory dependencies in editable mode

What it means

poetry.utils.pip.pip_install with editable=True checks path.is_dir() and raises PoetryError if false. Editable (`pip install -e`) installs require a project source directory; wheels, sdists, or non-existent paths are not valid.

Source

Thrown at src/poetry/utils/pip.py:48

        "--disable-pip-version-check",
        "--isolated",
        "--no-input",
        "--prefix",
        str(environment.path),
    ]

    if not is_wheel and not editable:
        args.insert(1, "--use-pep517")

    if upgrade:
        args.append("--upgrade")

    if not deps:
        args.append("--no-deps")

    if editable:
        if not path.is_dir():
            raise PoetryError(
                "Cannot install non directory dependencies in editable mode"
            )
        args.append("-e")

    args.append(str(path))

    try:
        return environment.run_pip(*args)
    except EnvCommandError as e:
        raise PoetryError(f"Failed to install {path}") from e

View on GitHub (pinned to 92b74dcfe3)

Solutions

  1. Pass a project directory path (containing pyproject.toml/setup.py) when editable=True.
  2. If the target is a wheel, call pip_install with editable=False.
  3. Verify the path exists and is a directory before requesting editable mode.

Example fix

# before
pip_install(Path('pkg-1.0-py3-none-any.whl'), env, editable=True)
# after
pip_install(Path('./pkg-1.0-py3-none-any.whl'), env, editable=False)
# or, for a local project checkout:
pip_install(Path('./myproject'), env, editable=True)
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def can_editable_install(path: Path) -> bool:
    return path.is_dir()

Try / catch

from poetry.exceptions import PoetryError
try:
    pip_install(path, env, editable=True)
except PoetryError as e:
    if 'editable' in str(e):
        # fall back to a non-editable install
        pip_install(path, env, editable=False)
    raise

Prevention

When it happens

Trigger: Calling pip_install(path, env, editable=True) where path is a .whl file, a .tar.gz sdist, or a path that does not exist.

Common situations: Misconfigured dependency declaration asking for an editable install of a wheel/sdist; passing a file path where a directory is expected; a directory path that has a trailing typo so is_dir() is false.

Related errors


AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04). Data as JSON: /data/errors/60603da3aa5a02d8.json. Report an issue: GitHub.