89

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.

bad_coder
  • 11,289
  • 20
  • 44
  • 72
sP_
  • 1,738
  • 2
  • 15
  • 29
  • welcome to the community! please try to give more specific examples and include code if possible – Tadhg McDonald-Jensen Jan 24 '16 at 12:57
  • 6
    I'm not sure what example you want. I think the problem is not with the code as it happened without even running it. The problem can be seen here [link](http://imgur.com/7LrcL6P). The process doesn't end so I cannot run or debug anything. – sP_ Jan 24 '16 at 13:00
  • What do the [logs](https://devnet.jetbrains.com/docs/DOC-181) say? – georg Jan 24 '16 at 13:04
  • 11
    dear pycharm developers, please learn about threads. indexing freezes the UI. – thang Feb 06 '18 at 19:03

11 Answers11

93

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.

www.data-blogger.com
  • 4,076
  • 7
  • 43
  • 65
  • 1
    Which folders do I not want to index? This isn't something I turned on... – endolith Feb 25 '23 at 02:12
  • I guess all your Python environment and Python system libraries, that are indexed for autocompletion, etc [1][2]. What I don´t know is why they do not index that just once, and then re-index only after detecting some subdirectory changes, instead of every time you re-open the same project in the same environment. [1] https://www.jetbrains.com/help/pycharm/indexing.html#exclude [2] https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000131704-Stop-continuous-indexing-of-libs-directory-in-PyCharm#:~:text=In%20order%20to%20stop%20PyCharm,longer%20be%20indexed%20by%20PyCharm. – xCovelus Aug 16 '23 at 08:02
21

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.

Yishai E
  • 481
  • 3
  • 9
10

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

Ihor Pomaranskyy
  • 5,437
  • 34
  • 37
8

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.
  • Make sure you do not have any duplicate virtual environments with the same name. Especially ones created by different environment managers (poetry, conda, pyenv, virtualenv, etc)
  • You just had this problem for the first time. Use File > Invalidate Cache and Restart
  • If that did not work, use the File > Repair IDE
  • 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.
Roelant
  • 4,508
  • 1
  • 32
  • 62
2

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.

grand_chat
  • 431
  • 3
  • 3
2

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

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

Apply good luck !

2

Don't install packages to python3 directly, globally
Consider a situation, where you have multiple projects, not all projects require library like pygame, flask...
If you open a specific project in pycharm, with python 3.x as interpreter, it will index all its modules.
So uninstall all preinstalled modules
You will be left over with wheel, pip, and the default ones
Now configure a VirtualEnvironment for each of your projects, as a local interpreter in PyCharm, and install only necessary modules.

I just did uninstall everything and reinstall inside small private venv's. For windows:
pip uninstall > requirements.txt
pip uninstall -r requirements.txt -y (-y makes yes to all the questions - if it should start deleting)

Neptotech -vishnu
  • 1,096
  • 8
  • 23
dorBrex
  • 21
  • 2
1

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

testCoder
  • 7,155
  • 13
  • 56
  • 75
0

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!

kusiroll
  • 374
  • 5
  • 9
0

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.

mehmet sahin
  • 802
  • 7
  • 21
0

Background: I have Anaconda installed on my local computer, and PyCharm defaults to using the Anaconda environment. When I open a new project folder in PyCharm (without configuring an interpreter), PyCharm automatically creates a Python virtual environment "venv" in the project folder. However, it gets stuck at "PyCharm is scanning files to establish indices.(scanning Python SDK)"

The reason is that PyCharm's scanning includes the conda base environment, which causes the delay.Remove the paths of conda base environment and it's fine.The figures of operations is following.


Show all interpreters

Show all interpreters

Click this button:

Click this button

Remove these paths:

Remove these paths

Trasp
  • 1,132
  • 7
  • 11
Frank
  • 1
  • 1
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/34711956) – Chenmunka Jul 21 '23 at 18:13