Reputation: 363213
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?
Upvotes: 29
Views: 24185
Reputation: 363213
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.
Upvotes: 6
Reputation: 12910
You can globally exclude a directory in PyCharm by following the Breadcrumb trail:
Settings > Editor > File Types > Ignore Files and Folders:
At the bottom is a text box where you can input the symbolic link ./venv
relative to your projects base directory, highlighted in the picture:
After that, new projects have ./venv
excluded by default. You don't need to repeat the above steps for new projects. In use, "Find in Path" shows:
P.S. I also started keeping my venvs inside their project directories. Once you have dozens of projects it just becomes convenient.
Upvotes: 18
Reputation: 3087
In File > Settings > Project: > Project Structure
at the bottom is Exclude files:
You can put something in there like
venv
or venv;coverage.xml
(given your comment)
It doesn't seem to recognize paths (e.g. foo/venv
), but this does what you requested.
Upvotes: 19