'How to prevent PyCharm's "Find in Files" to search the Python interpreter libraries?

I am trying to find some pattern within files like my project's setup.py / setup.cfg', rio.yaml. Our code .. So within the Find in Files dialog I selected the Directory option. However the python libraries are still being searched:

enter image description here

That was a surprise: I had expected those to only show up if the Project were selected. So how can the Python libraries be excluded?

I have even manually excluded the virtual environment (.venv and friends) directories.

enter image description here

The files are still being searched under that .venv directory

enter image description here

I am on PyCharm Professional 2021.3.1.



Solution 1:[1]

TL;DR: For readers who are busy and just want a quick-fix to get on with their work I usually recommend narrowing search using scope thereby you can explicitly exclude any paths that are polluting your search results.

I think this might be a PyCharm 2021.3.1 specific bug (see this excellent answer to the PY-51643 issue on JetBrains bugtracker). It should be possible to fix the issue by manually configuring some IDE settings, however the solution is dependent on a very specific interpreter/project setup so reproducing the conditions of the bug requires setting up an entire environment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 bad_coder