PyCharm Unresolved Reference

In PyCharm you may face errors like:

Unresolved reference 'print'

or

Unresolved reference 'end'

You have several possible ways to solve them

Change run configuration

The first thing to try is to change the running configuration by

  • Run
  • Edit Configuration
  • Project Interpreter

Change the python interpreter from python 2 to python 3 for example and test again.

Change project python interpreter

One of the reasons for getting this error is wrong python version - running python 3 code with python 2 interpreter. In order to solve this problem you need to setup the correct python interpreter by:

Adding new default interpreter

  • File
  • Default Settings
  • Project Interpreter left menu
  • Project Interpreter drop box
  • Show all
  • Click green plus - to add new interpreter
  • Select the python version
    • customize the new interpreter

Setup interpreter for the project

  • File
  • Settings
  • Project Interpreter left menu
  • Project Interpreter - select the python interpreter( the one added in previous point)

Invalidate cache

If you still face error after changing the python interpreter than you can try to invalidate project cache. This can be done by:

  • File
  • Invalidate Caches / Restart
  • Invalidate and Restart