{"id":"6089430a6265dcd2","repo":"pypa/pip","slug":"cannot-determine-archive-format-of-location","errorCode":null,"errorMessage":"Cannot determine archive format of {location}","messagePattern":"Cannot determine archive format of (.+?)","errorType":"exception","errorClass":"InstallationError","httpStatus":null,"severity":"error","filePath":"src/pip/_internal/utils/unpacking.py","lineNumber":407,"sourceCode":"\n    # avoid ambiguous case where both signature checks return True\n    is_zipfile = zipfile.is_zipfile(filename)\n    is_tarfile = tarfile.is_tarfile(filename)\n    if is_zipfile and not is_tarfile:\n        return _unzip()\n    if is_tarfile and not is_zipfile:\n        return _untar()\n    if is_zipfile and is_tarfile:\n        logger.error(\"Ambiguous file signature in %s.\", filename)\n\n    logger.critical(\n        \"Cannot unpack file %s (downloaded from %s, content-type: %s); \"\n        \"cannot detect archive format\",\n        filename,\n        location,\n        content_type,\n    )\n    raise InstallationError(f\"Cannot determine archive format of {location}\")\n","sourceCodeStart":389,"sourceCodeEnd":408,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_internal/utils/unpacking.py#L389-L408","documentation":"InstallationError raised by unpack_file when pip cannot determine whether an archive is a zip or tar. After checking content-type and file extension, pip probes with zipfile.is_zipfile and tarfile.is_tarfile; if both return False (or both True, the ambiguous case logged at critical), it gives up. This indicates a file that is neither a supported archive nor recognized by signature.","triggerScenarios":"Calling unpack_file on a downloaded/cached file whose extension is unknown, content-type is unhelpful, and whose magic bytes are neither zip nor tar. Common with renamed files, HTML error pages saved with archive extensions, or zero-byte downloads.","commonSituations":"Index returned an HTML 404/login page saved as the .whl; a gzip-compressed single file (not a tar); an unsupported compression like zstd alone; truncated download; the URL redirected through a CDN that served a placeholder.","solutions":["Inspect the file: `file path` and `head -c 512 path | xxd` to see what was actually downloaded.","Re-download with `-v` to see the resolved URL and HTTP status; verify content-type.","Confirm the file is a real archive: try `unzip -t` or `tar -tvf` manually.","If using a private index, check its auth/URL configuration so it serves the artifact instead of a redirect/HTML page."],"exampleFix":"// before\n# index served an HTML 404 page; pip cached it as the wheel\npip install pkg-1.0-py3-none-any.whl\n\n// after\n# fix the index URL / auth, clear the cache, retry:\npip cache purge && pip install -i https://pypi.org/simple/ pkg==1.0","handlingStrategy":"validation","validationCode":"import zipfile, tarfile, os\nEXTS = ('.zip','.whl','.egg','.tar','.tar.gz','.tgz','.tar.bz2','.tbz2','.tar.xz','.txz')\ndef looks_like_archive(path: str) -> bool:\n    if path.lower().endswith(EXTS):\n        return True\n    return zipfile.is_zipfile(path) or tarfile.is_tarfile(path)","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Verify the download URL resolves to a real artifact (check status code + content-type).","Use trusted indexes over HTTPS.","Inspect suspicious files with `file path` before install.","Configure private index auth correctly so it doesn't serve HTML."],"tags":["pip","archive","unpack","download","configuration"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}