sP_
sP_

Reputation: 1866

Pycharm: "scanning files to index" is taking forever

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.

Upvotes: 98

Views: 82967

Answers (13)

Valiantsin Dzerakh
Valiantsin Dzerakh

Reputation: 11

Go to “File” > “Invalidate Caches / Restart” and select “Invalidate and Restart.” This will clear the cache and force PyCharm to reindex your project.

Upvotes: 1

Yishai E
Yishai E

Reputation: 521

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.

Upvotes: 24

user23009011
user23009011

Reputation: 1

I had a similar issue. The problem turned out to be that my PyCharm project was stored under my Mac's desktop folder. I have ICloud turned on for everything on my ~/Desktop so parts of the project weren't actually stored locally on my computer. I moved it into ~/PycharmProjects instead and now it works fine.

Upvotes: 0

Roelant
Roelant

Reputation: 5119

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

  • You're using an old version of PyCharm; it really got a lot better, so consider updating.
  • 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 have the right environment set, and not eg multiple environments. Chek via File > Settings > Interpreters
  • 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.

Upvotes: 13

Frank
Frank

Reputation: 1

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

Upvotes: 0

dorBrex
dorBrex

Reputation: 21

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)

Upvotes: 2

testCoder
testCoder

Reputation: 7385

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

Upvotes: 3

Juan Carlos Vargas
Juan Carlos Vargas

Reputation: 21

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

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

Apply good luck !

Upvotes: 2

mehmet sahin
mehmet sahin

Reputation: 812

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.

Upvotes: 0

grand_chat
grand_chat

Reputation: 541

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.

Upvotes: 2

kusiroll
kusiroll

Reputation: 374

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!

Upvotes: 0

www.data-blogger.com
www.data-blogger.com

Reputation: 4164

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.

Upvotes: 98

Ihor Pomaranskyy
Ihor Pomaranskyy

Reputation: 5641

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

Upvotes: 11

Related Questions