{"id":"2f2e8330d73834a6","repo":"python-poetry/poetry","slug":"failed-to-download-and-install-requested-version-o","errorCode":null,"errorMessage":"Failed to download and install requested version of Python.","messagePattern":"Failed to download and install requested version of Python\\.","errorType":"exception","errorClass":"PythonInstallationError","httpStatus":null,"severity":"error","filePath":"src/poetry/utils/env/python/installer.py","lineNumber":113,"sourceCode":"                    ],\n                ],\n            )\n\n        return False\n\n    def install(self) -> None:\n        try:\n            # this can be broken into download, and install_file if required to make\n            # use of Poetry's own mechanics for download and unpack\n            pbi.install(\n                self.request,\n                self.installation_directory,\n                version_dir=True,\n                implementation=self.implementation,\n                free_threaded=self.free_threaded,\n            )\n        except ValueError:\n            raise PythonInstallationError(\n                \"Failed to download and install requested version of Python.\"\n            )\n","sourceCodeStart":95,"sourceCodeEnd":116,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/utils/env/python/installer.py#L95-L116","documentation":"Raised as PythonInstallationError in PythonInstaller.install when pbs_installer.install() raises ValueError during the download+extract+place sequence. It signals a failure of the actual acquisition step, distinct from a version-not-found error.","triggerScenarios":"Calling PythonInstaller(...).install() and pbs_installer.install() raises ValueError - e.g. the download was interrupted/corrupted, the archive failed integrity/extraction, or the destination path conflicts. Exact catch: installer.py:101-115.","commonSituations":"Network drop during download leaving a partial archive; the installation_directory is not writable or is full; a proxy/firewall corrupts the tarball; the version was withdrawn from the index between the lookup and the download; concurrent installs racing on the same version_dir.","solutions":["Retry on a stable network connection; clear any partial files under the installation/version directory first.","Verify the installation_directory is writable and has disk space.","Disable/adjust HTTP proxies that might be mangling the download.","Retry; if it persists, remove the version dir entirely and 'poetry python install <version>' again."],"exampleFix":"// before - partial/corrupted download\nPythonInstaller(request=\"3.12\").install()  # -> PythonInstallationError\n\n// after - clean and retry\n# rm -rf <installation_dir>/python-3.12 && poetry python install 3.12","handlingStrategy":"retry","validationCode":"import os\nfrom pathlib import Path\n\ndef install_dir_ready(d: Path) -> bool:\n    return os.access(d, os.W_OK) and d.exists() and has_free_space(d)","typeGuard":"from poetry.utils.env.python.installer import PythonInstallationError, PythonInstallerError\n\ndef is_python_installation_error(e: Exception) -> bool:\n    return isinstance(e, PythonInstallationError) or isinstance(e, PythonInstallerError)","tryCatchPattern":"from poetry.utils.env.python.installer import PythonInstallationError\n\nimport time\nfor attempt in range(3):\n    try:\n        PythonInstaller(request=req).install()\n        break\n    except PythonInstallationError:\n        clean_partial(installer.installation_directory, req)\n        if attempt == 2:\n            raise\n        time.sleep(2 ** attempt)","preventionTips":["Run installs on a stable network; retry transient download failures.","Clear partial archives in the version dir before retrying.","Ensure the installation directory is writable and has free space.","Disable/adjust proxies that could corrupt downloads."],"tags":["python-install","download","extraction","python-build-standalone"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}