{"id":"ae6beb83da876954","repo":"python-poetry/poetry","slug":"warning-environment-python-does-not-exist-w","errorCode":null,"errorMessage":"<warning>Environment \"{python}\" 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":308,"sourceCode":"                ):\n                    raise IncorrectEnvError(env_name)\n            except CalledProcessError as e:\n                raise EnvCommandError(e)\n\n        if self.check_env_is_for_current_project(python, self.base_env_name):\n            venvs = self.list()\n            for venv in venvs:\n                if venv.path.name == python:\n                    # Exact virtualenv name\n                    if self.envs_file.exists():\n                        venv_minor = \".\".join(str(v) for v in venv.version_info[:2])\n                        self.envs_file.remove_section(self.base_env_name, venv_minor)\n\n                    self.remove_venv(venv.path)\n\n                    return venv\n\n            raise ValueError(\n                f'<warning>Environment \"{python}\" does not exist.</warning>'\n            )\n        else:\n            venv_path = self._poetry.config.virtualenvs_path\n            # Get all the poetry envs, even for other projects\n            env_names = [p.name for p in sorted(venv_path.glob(\"*-*-py*\"))]\n            if python in env_names:\n                raise IncorrectEnvError(python)\n\n        try:\n            python_version = Version.parse(python)\n            python = f\"python{python_version.major}\"\n            if python_version.precision > 1:\n                python += f\".{python_version.minor}\"\n        except ValueError:\n            # Executable in PATH or full executable path\n            pass\n","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/python-poetry/poetry/blob/92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54/src/poetry/utils/env/env_manager.py#L290-L326","documentation":"Raised as ValueError in EnvManager.remove when the given name passes the project-ownership check (it starts with base_env_name) but none of the venvs returned by self.list() has a matching path.name. I.e., the env name looks like it belongs to this project but no such virtualenv is registered.","triggerScenarios":"Calling 'poetry env remove <name>' where <name> matches the project prefix but the concrete venv was already deleted, never created, or lives outside the discovered virtualenvs_path. Exact branch: env_manager.py:295-310.","commonSituations":"The venv directory was deleted by hand (rm -rf) but the user still references it; the virtualenvs_path changed between invocations; a typo in the env name that still happens to share the prefix; running after a cache cleanup tool removed envs.","solutions":["List actual envs for this project: 'poetry env list' and remove one that appears there.","If the env dir was deleted by hand, the message is effectively a no-op - nothing to remove; ignore it.","Check that virtualenvs_path in config still points where the env was created.","Recreate the env with 'poetry install' if you still need it."],"exampleFix":"// before\nmanager.remove(\"myproject-py3.99\")  # never created -> ValueError\n\n// after - remove an env that actually exists\nmanager.remove(\"myproject-py3.11\")","handlingStrategy":"validation","validationCode":"def env_exists_for_project(manager, name: str) -> bool:\n    if not manager.check_env_is_for_current_project(name, manager.base_env_name):\n        return False\n    return any(venv.path.name == name for venv in manager.list())","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(name)\nexcept ValueError as e:\n    if 'does not exist' in str(e):\n        # already gone - nothing to do\n        pass\n    else:\n        raise","preventionTips":["Call 'poetry env list' to confirm the env name exists for this project before removing.","Treat 'does not exist' as effectively a no-op when the dir was already deleted by hand.","Avoid manual rm -rf of venv dirs to keep Poetry's view consistent.","Remember the warning tag - this is informational, not a hard failure."],"tags":["env-remove","missing-env","virtualenv","no-op"],"analyzedSha":"92b74dcfe348d0e01e14d40d6c1fa47a4ee04a54","analyzedAt":"2026-08-04T20:33:34.072Z","schemaVersion":2}