Poetry keeps a virtual environment for every project, and they stay after the project is gone
Poetry stores its package cache and every project's virtualenv in your Library by default. How to list them, remove stale ones and clear the cache.
Poetry creates a virtual environment for each project and keeps them all in one place, outside the project. Delete the project folder and its environment stays. Each can be hundreds of MB, more with data science libraries.
du -sh ~/Library/Caches/pypoetry 2>/dev/null
du -sh ~/Library/Caches/pypoetry/virtualenvs/* 2>/dev/null | sort -h | tail
poetry config cache-dirRemove environments
# From inside a project
poetry env list
poetry env remove --allFor projects that no longer exist, delete their folders from the virtualenvs directory directly. The names start with the project name.
Clear the package cache
poetry cache list
poetry cache clear PyPI --allKeeping environments inside projects makes them easier to clean up with the project: poetry config virtualenvs.in-project true. Other Python caches: Python taking up space and uv cache.
Common questions
Where does Poetry store virtual environments on a Mac?
By default in ~/Library/Caches/pypoetry/virtualenvs. poetry config cache-dir shows the base folder.
How do I clear Poetry's cache?
Run poetry cache clear PyPI --all. poetry cache list shows which caches exist.
Do Poetry environments get deleted with the project?
No, unless virtualenvs.in-project is on. Otherwise they stay in Poetry's cache folder until removed.