Search code examples
pythonpycharmvirtualenv

PyCharm: always mark venv directory as excluded


In Python 3, I've moved away from creating virtualenvs in ~/.virtualenvs and towards keeping them in the project directory ./venv

However now search results in every PyCharm project include results from venv subdirectories, until you manually right-click and exclude them from the project.

How to omit directories named venv from PyCharm indexing/searching, globally?


Solution

  • The default behavior in recent versions of PyCharm now excludes venv (and .venv) on new projects. I can not find a related issue on their tracker nor a mention in the changelog, so I don't know in which version this was fixed, but it's no longer an issue in 2021.3.3 at least.

    If you're still seeing the old behaviour, consider to update your PyCharm version.