Indexing excluded directories in PyCharm 3
Solution 1
if i am right: File | Settings | project structure and select the folders you need and click exlcuded.
from documentation
Mark a folder as an excluded root.
Excluded roots are not visible to PyCharm. Usually, one would like to exclude temporary >build folders, generated output, logs, and other project output. Excluding the unnecessary >paths is a good way to significantly improve performance.
This command is duplicated on the context menu of a content root.
Solution 2
Besides @FooBarUser's suggestion, you can go to Preferences->Editor->File Types
and here you have a box where you can add the files and folders you want to exclude from your project.
The folders and files that you include will not be shown in your project.
Solution 3
In PyCharm 2017.2.4 you can cmd+shift+A
and start typing project structure... the project structure
option should show up, then press <enter>
. Then you can highlight the folder you want to exclude and mark it as Exclude
. This is useful when you want to search for files with cmd+shift+O
and you don't want venv
files to showed up.
Solution 4
As PyCharm (EC 2021.2) still suffers from the issue I take myself the liberty to answer what @LazyOne hinted in their comment 8 years ago.
While (as already mentioned) there are excluded directories, in https://youtrack.jetbrains.com/issue/PY-5459 you can read that:
...indexing in PyCharm is performed at application level (and the index is shared between all projects), and the excluded directories are per-project. When PyCharm is indexing the interpreter paths, it's not possible to know whether any paths are excluded from any of the projects that the user has opened or might decide to open in the future.
and
The issue happens only when your data folder is a subdirectory of a directory in your sys.path, which should be avoidable in most cases.
What helped in my case was unmarking the superdirectory as Sorce Roots (which removed it from sys.path
).
philroche
Updated on July 15, 2022Comments
-
philroche almost 2 years
I am trying to exclude some directories from Pycharm's project index as they are recursive symbolic links. I have excluded the directories and invalidated the caches and restarted but PyCharm still indexes these excluded directories. It does not result in duplicate results in my search results etc. but indexing takes so much longer.
Is there a way to exclude these directories from being indexed?
-
philroche over 10 yearsI have excluded the directories but they continue to be indexed. See youtrack.jetbrains.com/issue/IDEA-52055 which LazyOne linked to.
-
David Fraser over 10 yearsThis is probably because those folders are still in your library path; PyCharm will continue to index such folders unless you exclude them from the library; see youtrack.jetbrains.com/issue/IDEA-88958
-
storm_m2138 almost 9 yearsWith regard to the above comment by @DavidFraser -- Pycharm uses the $PYTHONPATH variable to index, so removing the directories from your python path on the command line may help. Also might try File --> Invalidate Caches / Restart in Pycharm after making the changes.
-
Sun Liwen about 8 yearsIn PyCharm 2016, right click on the directory to exclude ->
Mark Directory As -> Excluded
. -
Alexandre Neto about 7 yearsThis really nailed it for me as, in my case, Pycharm was trying to index a bunch of eps files that I have scattered across the project folders.
-
chongkai Lu over 2 yearsLife saver!
Excluded
doesn't work for me at all. -
matanster over 2 yearsThere's an open feature request to automatically infer directories to exclude from the git ignore file, or at least provide an option towards that
-
father_goose about 2 yearsremoving the superdirectory from Sources Root wasn't an option for me, as it broke PyCharm's ability to recognize my app's import statements. In my case, the solution was to ensure all the tools I was running that created output I didn't want indexed were doing so one directory up from my Sources Root (nox, coverage, etc). No more "found 32,234 changed files...." messages.