Pycharm: "scanning files to index" is taking forever

Question:

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.

Asked By: sP_

||

Answers:

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.

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

Answered By: Ihor Pomaranskyy

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.
Answered By: Roelant

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.

Answered By: Yishai E

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!

Answered By: kusiroll

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.

Answered By: grand_chat

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.

Answered By: mehmet sahin

File -> Setting… -> tools -> Shared Indexes -> Python Packages

choose the option that says: "Don’t download, use local indexes"

Apply good luck !

Answered By: Juan Carlos Vargas

The following steps helped me in Rider IDE:

1) delete .idea folder.

2) Go to File > Settings > Python Interpreter Node
enter image description here

3) From the dropdown next to Python Interpreter label choose Show All
enter image description here

4) In the python Interpreters window click Show Interpreters paths:
enter image description here

5) If C: is present in the list of paths, it must be deleted by clicking the minus button above. Because I guess it is scanned every time which takes infinity.

enter image description here

Answered By: testCoder
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.