Pycharm: "scanning files to index" is taking forever

Exclude the folders you do not want to index. You can do this by right-clicking the folder you want to exclude, then choose Mark Directory As > Excluded and PyCharm will not index those files.


In some cases, this is because Pycharm scans and indexes the PYTHONPATH. I figured out that some shared script I was running got changed by some nincompoop (may his severed head soon decorate our moat) and the /homes directory got into the PYTHONPATH.

How to get it out: Go to File->Settings->Project:[your project]->Project Interpreter

On the right hand side you'll see a cogwheel, click it, then select Show all...

In the next window, your environment will be selected. There are a few icons on the right hand side of this window, one of them is a directory tree. Click it.

You'll find a list of all interpreter paths. Remove the directory that is causing your problem, dance a little victory dance, and resume work.