{"id":"777dd1616ac96168","repo":"python-poetry/poetry","slug":"warning-environment-name-does-not-exist-war","errorCode":null,"errorMessage":"<warning>Environment \"{name}\" does not exist.</warning>","messagePattern":"<warning>Environment \"(.+?)\" does not exist\\.</warning>","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"src/poetry/utils/env/env_manager.py","lineNumber":343,"sourceCode":"            pass\n\n        try:\n            python_version_string = subprocess.check_output(\n                [python, \"-c\", GET_PYTHON_VERSION_ONELINER],\n                text=True,\n                encoding=\"locale\",\n            )\n        except CalledProcessError as e:\n            raise EnvCommandError(e)\n\n        python_version = Version.parse(python_version_string.strip())\n        minor = f\"{python_version.major}.{python_version.minor}\"\n\n        name = f\"{self.base_env_name}-py{minor}\"\n        venv_path = venv_path / name\n\n        if not venv_path.exists():\n            raise ValueError(f'<warning>Environment \"{name}\" does not exist.</warning>')\n\n        if self.envs_file.exists():\n            self.envs_file.remove_section(self.base_env_name, minor)\n\n        self.remove_venv(venv_path)\n\n        return VirtualEnv(venv_path, venv_path)\n\n    def use_in_project_venv(self) -> bool:\n        in_project: bool | None = self._poetry.config.get(\"virtualenvs.in-project\")\n        if in_project is not None:\n            return in_project\n\n        return self.in_project_venv.is_dir()\n\n    def in_project_venv_exists(self) -> bool:\n        in_project: bool | None = self._poetry.config.get(\"virtualenvs.in-project\")\n        if in_project is False:","sourceCodeStart":325,"sourceCodeEnd":361,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/utils/env/env_manager.py#L325-L361","documentation":"Raised as ValueError in EnvManager.remove when the interpreter probe succeeded and Poetry computed the expected venv name (base_env_name + '-py' + minor) but that directory does not exist under virtualenvs_path. The env was expected for the discovered python version but is absent.","triggerScenarios":"Calling 'poetry env remove <python-version-or-interpreter>' where the version resolves correctly but no venv directory '{base_env_name}-py{minor}' exists (env_manager.py:339-343).","commonSituations":"Asking to remove a python version's env that was never created; the env was already removed; the venv was created in-project (virtualenvs.in-project=true) so nothing lives in virtualenvs_path; virtualenvs_path was changed/relocated.","solutions":["Check 'poetry env list' to see which envs actually exist for this project.","If using in-project venvs, remove the .venv directory manually instead.","Confirm virtualenvs_path config matches where envs were created.","Treat as informational if the env is already gone - nothing to remove."],"exampleFix":"// before\nmanager.remove(\"3.12\")  # no myproject-py3.12 dir exists -> ValueError\n\n// after - remove a version that has an env\nmanager.remove(\"3.11\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef expected_venv_exists(manager, python_version: str) -> bool:\n    from poetry.core.constraints.version import Version\n    v = Version.parse(python_version)\n    minor = f\"{v.major}.{v.minor}\"\n    name = f\"{manager.base_env_name}-py{minor}\"\n    return (manager._poetry.config.virtualenvs_path / name).exists()","typeGuard":"def is_missing_env_value_error(e: Exception) -> bool:\n    return isinstance(e, ValueError) and 'does not exist' in str(e)","tryCatchPattern":"try:\n    manager.remove(\"3.12\")\nexcept ValueError as e:\n    if 'does not exist' in str(e):\n        # no env for this version - nothing to remove\n        pass\n    else:\n        raise","preventionTips":["Check 'poetry env list' to see which versions actually have envs before removing.","If you use in-project venvs, remove the .venv dir manually instead of by version.","Confirm virtualenvs_path hasn't been reconfigured away from where envs were created.","Treat the warning as informational - the env is already absent."],"tags":["env-remove","missing-env","virtualenv","no-op"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}