Not able to view code when I open the Python file or Project after 'Invalidating Cache'

PyCharm was giving me unnecessary error even though my program was running fine. I came to know that we can do 'Invalidate Cache' to solve this problem. But after doing that, I am unable to view my code when I open the project or the scripts. Those scripts are still there in the directory but I am not able to view it. when I open it in PyCharm


I see a progress bar at the bottom of pycharm when I start it up for the first time after invalidating the cache. Pycharm has to rebuild the skeletons.  Is it doing this? 



Yes, It keeps updating the skeletons and indexing for upto 2 hours everyday when I open my PyCharm. Is there any way to stop this automatic updates. It would seem an easy solution to this problem, but I have searched everywhere and couldn't find anything how to do it.


If it's taking that long, there is a good chance Pycharm is indexing more than you want. 

I noticed that when I had a larger project that included logs, text files, databases, etc, Pycharm would get bogged down trying to index those.  I set those folders to be excluded form the project structure.  I excluded pretty much any folder that didn't include source code for my project.  In some rare cases I had to exclude file patterns.



  • So I can't find anything in my folder, Am i looking it correctly? Because this folder has 3-4 scripts and lots of files in it

Untitled is your root folder.  Within it are lots of files?  If so, you likely need to exclude these files. 

example: I want to exclude all txt and png.  I add the pattern like this:

You'll know you did it correctly when you look in the project and see those file types colored differently from the rest of the project.



Can you please help me locate where the 'Exclude Files' option is? All I can see is 'Sources' and 'Excluded'. It selects either excluded or sources if I select the folder. 


I have selected my Pycharm Project folder as the root folder yet I couldn't find my scripts and files in these projects and there is no option 'Excluded Files'. I am using Pycharm Community Edition 2016.2.2. Could it be because of that? My version is different?


Ahh, I'm using 2018.2.  

Regardless of the individual files, you can still exclude whole folders that don't need indexing.


Got it. Probably, I will exclude the whole folder :P I am so irritated with the indexing now.

So selecting the root folder as my whole Pycharm Projects folder and excluding all of them won't harm my data, right? I tried StackOverflow answers and questions and it made me do 'Invalidate Cache' and I had to lose all of my scripts previously. 


Invalidating cache does not delete scripts.  It's just clearing out the indexes. 


As a general rule I only include source files in my Pycharm projects.  Occasionally there are folders that get included (like log files) which don't need indexing.  Excluding them does not harm the files in any way.  They simply are being ignored by Pycharm.

I also tend to have smaller projects rather than a giant super project which contains all my source across multiple applications.  

Just keep in mind; the more files pycharm has in a project, the more longer indexing is going to take.

My current project is around 15k lines of code in total and reindexing only takes maybe 20-30 seconds.  So if you're seeing indexing take more than a couple minutes, you've got files in your project that pycharm doesn't need to be scanning.

I know indexing has been improved over the last year or so, I would suggest you look at updating.  (I can't recall which version had the nice performance boost)


Got it! I will try this approach and see if it doesn't give me problems hopefully. Will have to update to the latest version, I believe! Thanks! I will get back here if it's still acting weird. :)


I would also not exclude the entire project folder.  This will cause pycharm to not be able to read your code and give realtime feedback.  You WANT your project indexed, at least the portions of it that are code related.  What you don't want is pycharm trying to index everything else.  (images, databases, .idea, logs, zip files, etc)


Please sign in to leave a comment.