{"id":"278c2e10f7599be3","repo":"python-poetry/poetry","slug":"package-link-url-cannot-be-installed-in-the-curr","errorCode":null,"errorMessage":"Package {link.url} cannot be installed in the current environment {self._env.marker_env}","messagePattern":"Package (.+?) cannot be installed in the current environment (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"src/poetry/installation/executor.py","lineNumber":764,"sourceCode":"        # Get original package for the link provided\n        download_func = functools.partial(self._download_archive, operation)\n        original_archive = self._artifact_cache.get_cached_archive_for_link(\n            link, strict=True, download_func=download_func\n        )\n\n        # Get potential higher prioritized cached archive, otherwise it will fall back\n        # to the original archive.\n        archive = self._artifact_cache.get_cached_archive_for_link(\n            link,\n            strict=False,\n            env=self._env,\n        )\n        if archive is None:\n            # Since we previously downloaded an archive, we now should have\n            # something cached that we can use here. The only case in which\n            # archive is None is if the original archive is not valid for the\n            # current environment.\n            raise RuntimeError(\n                f\"Package {link.url} cannot be installed in the current environment\"\n                f\" {self._env.marker_env}\"\n            )\n\n        if archive.suffix != \".whl\":\n            message = (\n                f\"  <fg=blue;options=bold>-</> {self.get_operation_message(operation)}:\"\n                f\"{format_build_wheel_log(package, self._env)}\"\n            )\n            self._write(operation, message)\n\n            name = operation.package.name\n            archive = self._chef.prepare(\n                archive,\n                output_dir=original_archive.parent,\n                config_settings=self._build_config_settings.get(name),\n                build_constraints=self._build_constraints.get(name),\n            )","sourceCodeStart":746,"sourceCodeEnd":782,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/installation/executor.py#L746-L782","documentation":"Raised by Executor._download_link_archive at src/poetry/installation/executor.py:759-767 when get_cached_archive_for_link(link, strict=False, env=...) returns None. With strict=False the cache is allowed to fall back to the original link, so a None result means the original archive itself is not valid for the current environment (no compatible candidate). RuntimeError naming the URL and the marker env.","triggerScenarios":"Installing a package whose only artifacts (cached or freshly downloaded) are incompatible with the current env's markers — e.g. a wheel only built for a different Python/OS, or an sdist that needs a build the env cannot satisfy. Occurs during executor.run when materializing the archive.","commonSituations":"Locked dependency resolved for a different interpreter than the one currently active; a wheel-only package on an unsupported platform; env markers (python_version, sys_platform) excluding every artifact.","solutions":["Verify and switch to the interpreter the lock was resolved with: `poetry env info`, `poetry env use <python>`.","Regenerate the lock for the current env: `poetry lock --regenerate` then install.","Ensure an sdist is available so Poetry can build for the platform, or add a compatible source.","Check markers in pyproject.toml (python = \"...\") match the active interpreter."],"exampleFix":"# before: lock made under py3.11, now in py3.9\n$ poetry install\nRuntimeError: Package ... cannot be installed in the current environment ...\n\n# after\n$ poetry env use python3.11\n$ poetry install","handlingStrategy":"validation","validationCode":"from poetry.utils.env import EnvManager\n\nenv = EnvManager.get_default_env()\nfor link in links:\n    if link.is_wheel:\n        from poetry.installation.wheel import Wheel\n        if not Wheel(link.filename).is_supported_by_environment(env):\n            continue\n    # ensure at least one link is env-compatible before install\n    break\nelse:\n    raise ValueError('No artifact compatible with the current env')","typeGuard":null,"tryCatchPattern":"try:\n    executor.run(operations)\nexcept RuntimeError as e:\n    if 'cannot be installed in the current environment' in str(e):\n        raise SystemExit('Use `poetry env use` to switch to the locked interpreter.') from e\n    raise","preventionTips":["Resolve and lock under the same interpreter family you install with.","Keep python constraint in pyproject.toml aligned with the deployment interpreter."],"tags":["environment","wheel","platform","installation","lock-file"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}