I want to search all my .py files for a certain expression, but it seems that Finder does not look at their content. Is this normal? What can I do?

(This question was also raised here.)

  • Where are the files? Spotlight doesn't search in system or hidden areas.
    – Tetsujin
    Commented Aug 27, 2022 at 5:50
  • @Tetsujin Spotlight does index nearly all files. And Finder can be told to include System and Hidden files.
    – Gilby
    Commented Aug 27, 2022 at 7:45
  • Could you add some details? We have several questions where people say they can’t search development related files you could model your edits after.
    – bmike
    Commented Aug 27, 2022 at 9:37
  • 1
    @Tetsujin The files are in standard locations (Documents/Desktop/...).
    – Karlo
    Commented Aug 27, 2022 at 23:50

1 Answer 1


On my MBP with macOS v12.5.1, Spotlight (also in Finder) brings out any Python code file that has the expression being searched for in contents.

Python code files are essentially text files. Make copies of a few in the same directory where the Python code files are located, rename their extensions as txt and see if those appear in your searches after a short while, assuming Spotlight is indeed active and indexing the files and directories on your computer. If even the new text files you created for testing don’t appear in your searches, then the directories they are placed in are excluded from Spotlight. In that case, you need to make sure those directories are not excluded via the System Preferences-> Spotlight -> Privacy window.

Otherwise or in addition to the above, make sure everything is checked under System Preferences -> Spotlight -> Search Results window, especially the Developer and Other categories.

Another issue could be what Python code files are associated with, i.e. which application opens them when they are double-clicked in Finder: on my MBP, they are associated with IDLE (the Python integrated development environment) and I can see contents of a Python file via Quick Look, i.e. by pressing space bar on any in Finder.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .