Pycharm: "scanning files to index" is taking forever

PythonPycharm

Python Problem Overview


I am using PyCharm Community Edition 5.0.1 It was working fine till yesterday. But it has been stuck at 'Scanning files to index' for a very long time now. Since yesterday.

I have tried re-installing it, and also tried invalidating cache.

I can make changes to programs and use it as a text editor but unable to run any file.

Python Solutions


Solution 1 - Python

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.

Solution 2 - Python

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.

Solution 3 - Python

Maybe there are some issues in project files? Try to remove .idea folder inside your project (but this will also purge all project settings).

Solution 4 - Python

In my experience it can be any of the following problems:

  • You added a new folder to your project which includes many files. Then follow the tip from sP_ and use Right click > Mark Directory As > Excluded

  • You added a zip file to your project. Then follow the tip from kusiroll and use Right click > Mark Directory As > Excluded. Or remove.

  • You just had this problem for the first time. Use File > Invalidate Cache and Restart

  • It happens on a specific project. If you're willing to give up all your project settings, delete the .idea folder of the project. The tip of Igor Pomaranskiy.

  • If you are working on linux you could check this answer in a similar question.

  • It keeps happening. If you're willing to give up all your settings, delete the ~\.PyCharm201X folder.

Solution 5 - Python

PyCharm will index every file unless told otherwise. The previous answers show you how to exclude a folder.

But if there are certain file types that you never need to index, such as log files, data files, compressed files, etc. (but for some reason happen to appear in your project), you can instruct PyCharm to ignore specific file extensions. Just append those file extensions to the list

> Preferences > Editor > File Types > Ignore Files and Folders

Use a semicolon to separate the entries.

Note that this is a global Ignore list; there doesn't seem to be a way to exclude extensions by project.

One way to discover which file types may be causing indexing to bog down is to identify the largest files in your codebase.

Solution 6 - Python

Try to make sure you have no compressed files in your directory, as removing this might show significant improvement in speed. it worked for me!

Solution 7 - Python

In my case, I tried every solution that are mentioned above or anything in the internet.

Lastly, I check environment variables and I removed old entries related with python.

Then it stopped indexing.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionsP_View Question on Stackoverflow
Solution 1 - Pythonwww.data-blogger.comView Answer on Stackoverflow
Solution 2 - PythonYishai EView Answer on Stackoverflow
Solution 3 - PythonIgor PomaranskiyView Answer on Stackoverflow
Solution 4 - PythonRoelantView Answer on Stackoverflow
Solution 5 - Pythongrand_chatView Answer on Stackoverflow
Solution 6 - PythonkusirollView Answer on Stackoverflow
Solution 7 - Pythonmehmet sahinView Answer on Stackoverflow