python-poetry/poetry · error · RuntimeError
Unable to retrieve the package version for {name}
Error message
Unable to retrieve the package version for {name} What it means
Raised by PackageInfo.to_package() at src/poetry/inspection/info.py:135-138 when the version field is falsy. Version is mandatory for a Package, so Poetry aborts with RuntimeError rather than silently using '0.0.0'.
Source
Thrown at src/poetry/inspection/info.py:138
"""
Create a new `poetry.core.packages.package.Package` instance using metadata from
this instance.
:param name: Name to use for the package, if not specified name from this
instance is used.
:param extras: Extras to activate for this package.
:param root_dir: Optional root directory to use for the package. If set,
dependency strings will be parsed relative to this directory.
"""
name = name or self.name
if not name:
raise RuntimeError(f"Unable to create package with no name for {root_dir}")
if not self.version:
# The version could not be determined, so we raise an error since it is
# mandatory.
raise RuntimeError(f"Unable to retrieve the package version for {name}")
package = Package(
name=name,
version=self.version,
source_type=self._source_type,
source_url=self._source_url,
source_reference=self._source_reference,
yanked=self.yanked,
)
if self.summary is not None:
package.description = self.summary
package.root_dir = root_dir
package.python_versions = self.requires_python or "*"
package.files = self.files
# If this is a local poetry project, we can extract "richer" requirement
# information, eg: development requirements etc.
if root_dir is not None:View on GitHub (pinned to 92b74dcfe3)
Solutions
- Ensure the inspected package's metadata exposes a concrete Version (set version in pyproject.toml [project] or pass it explicitly in setup.py).
- If using dynamic versioning, confirm the build backend (e.g. setuptools-git-versioning) actually produces a version at build time.
- Rebuild the artifact and verify with `python -m pkginfo ./dist/*.whl` that version is populated.
Example fix
# before [project] name = "my_pkg" # no version, no dynamic # after [project] name = "my_pkg" version = "0.1.0"
Defensive patterns
Strategy: try-catch
Validate before calling
from poetry.inspection.info import PackageInfo
info = PackageInfo.from_path(path)
if not info.version:
raise ValueError(f'No version in metadata for {info.name or path}; refusing to convert.')
pkg = info.to_package(root_dir=path) Type guard
def has_version(info: PackageInfo) -> bool:
return bool(getattr(info, 'version', None)) Try / catch
try:
pkg = PackageInfo.from_path(path).to_package(root_dir=path)
except RuntimeError as e:
if 'retrieve the package version' in str(e):
raise ValueError(f'Invalid package at {path}: missing version') from e
raise Prevention
- Set a concrete version in [project] / setup.py; avoid unresolved dynamic versioning at inspection time.
- Use `python -m pkginfo <archive>` to confirm version populates before publishing.
When it happens
Trigger: Inspecting a distribution whose metadata has no Version field, or whose version is empty/None. Triggered through PackageInfo.from_path/from_directory → to_package(), e.g. during `poetry add` or dependency resolution on a local package.
Common situations: A local package with dynamic versioning that didn't resolve at inspection time (PEP 621 `dynamic = ["version"]` without a backend that fills it), a hand-built sdist missing the Version header, or a legacy setup.py without version.
Related errors
- Unable to create package with no name for {root_dir}
- Unknown metadata version: {dist.metadata_version}
- Unable to determine package info from path: {file_path}
- Invalid author string. Must be in the format: John Smith <jo
- Invalid version constraint: {constraint}
AI-assisted analysis of python-poetry/poetry@92b74dcfe3 (2026-08-04).
Data as JSON: /data/errors/f45b59dc7d3b1086.json.
Report an issue: GitHub.