PyCharm Fails to resolve references to installed modules and even built-ins

from __future__ import print_function
from builtins import input as input
import getpass

from sqlalchemy.exc import OperationalError
from terminaltables import SingleTabl

I am using a virtualenv generated by PyCharm itself. I have tried using my own virtualenv, a pipenv interpreter, and even the base python interpreter.

I have tried uninstalling, deleting my .idea folder, deleting the files in %appdata%, deleting the install directory, and reinstalling. I then set up a new virtualenv and installed packages. I have tried every option in the Project Interpreter outside of Conda. I have tried invalidating caches and restarting.

PyCharm still does not resolve references to *any* installed packages, and cannot find some built-in packages such as json and getpass.



For the above snippet, the following errors are occuring:

unresolved reference __future__

unresolved reference print_function

No module named getpass

unresolved reference sqlalchemy

unresolved reference OperationalError

unresolved reference terminaltables

unresolved reference SingleTable




I would like to change this issue to a new Bug Report.

PyCharm does not set the Content Root to the site-packages directory when setting the project interpreter.

This wasted almost an entire day. Please add this to the Very Important bug list.



It seems you have found the root cause for the issue. Can you please provide a full steps to reproduce the issue from scratch? Starting from creating a new project.

The following steps have NOT reproduced the issue for me:

1. Create new project with the new Virtualenv

2. Paste the example from above

3. Install sqlalchemy and terminaltables modules, and wait for PyCharm to index

4. Unresolved error does not apper



This was a reoccurring issue up until I set the Content-Root. Every time PyCharm would update itself with the 'elevator' this would happen. I would try to break it again but I prefer not to waste time with this bug anymore.


Understood. Yes, things like that can happen between updates, I'll keep in mind to check content root if someone else will have the same issue.


Please sign in to leave a comment.