python-poetry/poetry · error · AttributeError

module {__name__!r} has no attribute {name!r}

Error message

module {__name__!r} has no attribute {name!r}

What it means

poetry.utils.helpers defines a module-level __getattr__. Names listed in _DEPRECATED_DOWNLOAD_EXPORTS (Downloader, download_file, HTTPRangeRequestSupportedError) are redirected to poetry.utils.download with a DeprecationWarning. Any other missing attribute triggers a standard AttributeError with this message. So the message only appears for genuinely non-existent names; the deprecated trio redirects silently (modulo the warning).

Source

Thrown at src/poetry/utils/helpers.py:352

_DEPRECATED_DOWNLOAD_EXPORTS = {
    "Downloader",
    "download_file",
    "HTTPRangeRequestSupportedError",
}


def __getattr__(name: str) -> object:
    if name in _DEPRECATED_DOWNLOAD_EXPORTS:
        warnings.warn(
            f"Importing `{name}` from `poetry.utils.helpers` is deprecated;"
            f" use `poetry.utils.download.{name}` instead.",
            DeprecationWarning,
            stacklevel=2,
        )
        from poetry.utils import download

        return getattr(download, name)
    raise AttributeError(f"module {__name__!r} has no attribute {name!r}")

View on GitHub (pinned to 92b74dcfe3)

Solutions

  1. For download-related symbols, import from poetry.utils.download instead of poetry.utils.helpers.
  2. Search the codebase (`grep -r <name> src/poetry`) to find the symbol's current module.
  3. Fix typos in the attribute/import name.
  4. Pin or upgrade Poetry to a version where the symbol exists if it was removed.

Example fix

# before
from poetry.utils.helpers import download_file  # works but deprecated
from poetry.utils.helpers import DownloaderXyz    # raises AttributeError
# after
from poetry.utils.download import download_file, Downloader
Defensive patterns

Strategy: type-guard

Validate before calling

import poetry.utils.helpers as h

name = 'download_file'  # attribute you intend to use
if name in h._DEPRECATED_DOWNLOAD_EXPORTS:
    # redirect target exists (will emit DeprecationWarning)
    pass
elif not hasattr(h, name):
    raise AttributeError(f'helpers has no attribute {name!r}')

Type guard

import poetry.utils.helpers as h

def is_helpers_attr(name: str) -> bool:
    return name in h._DEPRECATED_DOWNLOAD_EXPORTS or hasattr(h, name)

Try / catch

import poetry.utils.helpers as h
try:
    val = getattr(h, name)
except AttributeError:
    # import from the correct module instead, e.g. poetry.utils.download
    raise

Prevention

When it happens

Trigger: Accessing an attribute that does not exist on poetry.utils.helpers, e.g. `from poetry.utils.helpers import download_file_renamed` or `poetry.utils.helpers.some_helper`, OR a star-import/typo referencing a removed symbol. The deprecated download symbols do NOT raise this — they warn and redirect.

Common situations: A typo in an import; relying on a helper that was relocated (e.g. download utilities moved to poetry.utils.download); code written against an older Poetry version expecting a symbol that no longer exists.


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