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.


Comment actions Permalink

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



Comment actions Permalink

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.

Comment actions Permalink


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

Comment actions Permalink


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.

Comment actions Permalink

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.

Comment actions Permalink

A similar issue here.

from __future__ import print_function

Unresolved reference '__future__'
Unresolved reference 'print_function'

There is a similar issue with half of standard library modules, too:

import zipfile

Unresolved reference 'zipfile'

It seems to have started with some update, I have no other details.

Comment actions Permalink


Does not reproduce for me. I'm testing on PyCharm 2019.1.3, and tried both Python 2 and Python 3.

Can you please do the usual troubleshooting steps of **File > Invalidate caches / restart**, and/or deleting and recreating your project interpreter? Which interpreter do you use?

Comment actions Permalink


I apologize for filing my report as it was not justified. Due to some company-wide decisions I am using an interpreter wrapper (a simple Bash script which modifies some environment variables and launches the python executable with correct arguments). Setting this wrapper as my Project Interpreter in Settings -> Project -> Project Interpreter makes PyCharm recognize only some of the standard library modules - other modules are underlined as unrecognized. I was mistakenly thinking that this strange behavior was a result of some past PyCharm update a I tried to find a similiar bug report here on intellij-support.

However, could you advice me on how PyCharm learns the system paths related to the selected interpreter? If it is by calling the interpreter somehow maybe I could modify my wrapper to pass the correct results.

Thank you,

Comment actions Permalink

PyCharm constructs interpreter paths based on the sys.path of the given interpreter. Doesn't IDE report your interpreter as invalid? Which entries do you have in interpreter paths?

Comment actions Permalink

I've also had this problem in PyCharm. The problem for me was that my virtual envs were using a version of python which got removed when I updated Python using Homebrew. The virtual envs contained sym links to python files which included the patch version in the directory names.

To fix this I deleted all the sym links in the virtual env and recreated them, following one of the answers to this question on stack overflow.


Please sign in to leave a comment.