pypa/pip · error · PylockValidationError
path or url must be provided
Error message
path or url must be provided
What it means
Raised by _validate_path_url in pylock.py:245-247, called from the _from_dict of PackageVcs, PackageArchive, PackageSdist and PackageWheel. At least one of 'path' or 'url' must be a non-empty string; if both are missing/empty, PylockValidationError is raised (note: a vcs/archive/sdist/wheel still needs a fetchable location even when 'name' is set).
Solutions
- Add path = "..." or url = "..." to the vcs/archive/sdist/wheel entry.
- For VCS entries ensure 'url' (remote) or 'path' (local checkout) is present.
Example fix
# before [[packages]] name = "x" [packages.vcs] type = "git" commit-id = "abc" # after [[packages]] name = "x" [packages.vcs] type = "git" url = "https://example.com/x.git" commit-id = "abc"
Defensive patterns
Strategy: validation
Validate before calling
def has_path_or_url(path, url) -> bool:
return bool(path) or bool(url)
Try / catch
from packaging.pylock import Pylock, PylockValidationError
try:
Pylock.from_dict(d)
except PylockValidationError as e:
...
Prevention
- Always set path or url for every vcs/archive/sdist/wheel entry.
- Do not assume 'name' supplies a fetchable location.
When it happens
Trigger: A [[packages.vcs]] table with only type/commit-id but no path and no url; a sdist/archive/wheel entry with hashes and name but neither path nor url.
Common situations: Forgetting the source location; assuming 'name' implies a download URL.
Related errors
- At least one hash must be provided
- Cannot determine sdist filename
- Cannot determine wheel filename
- Cannot select requirements from pylock file
- Directory entries are not supported in remote pylock.toml
AI-assisted analysis of pypa/pip@f399c37189 (2026-08-08).
Data as JSON: /api/errors/c09d1847cb436890.
Report an issue: GitHub.
Appendix: source
Thrown at src/pip/_vendor/packaging/pylock.py:247
d: Mapping[str, Any], target_item_type: type[_FromMappingProtocolT], key: str
) -> Sequence[_FromMappingProtocolT]:
"""Get a required list value from the dictionary and convert its items to a
dataclass."""
if (result := _get_sequence_of_objects(d, target_item_type, key)) is None:
raise _PylockRequiredKeyError(key)
return result
def _validate_normalized_name(name: str) -> NormalizedName:
"""Validate that a string is a NormalizedName."""
if not is_normalized_name(name):
raise PylockValidationError(f"Name {name!r} is not normalized")
return NormalizedName(name)
def _validate_path_url(path: str | None, url: str | None) -> None:
if not path and not url:
raise PylockValidationError("path or url must be provided")
def _path_name(path: str | None) -> str | None:
if not path:
return None
# If the path is relative it MAY use POSIX-style path separators explicitly
# for portability
if "/" in path:
return path.rsplit("/", 1)[-1]
elif "\\" in path:
return path.rsplit("\\", 1)[-1]
else:
return path
def _url_name(url: str | None) -> str | None:
if not url:
return NoneView on GitHub (pinned to f399c37189)