PyCharm Unresolved reference 'print'

28,348

Solution 1

I have had the same problem as you, even though I configured Python 3.4.0 as the project's interpreter and all print's in the code were Python 3 compliant function calls.

I got it sorted out by doing this in PyCharm:

File -> Invalidate Caches / Restart... -> Invalidate and Restart

Solution 2

If you're in PyCharm and you're getting "Unresolved reference xrange" it's because xrange was removed in Python 3. Range takes over its functionality now. Was working on fast string concat from here:

https://waymoot.org/home/python_string/

And credit for the answer is from /r/learnpython:

https://www.reddit.com/r/learnpython/comments/2udj3s/pycharm_issue/

Solution 3

This could be related to the version of python you are using. Under python 2.x print is a statement:

print "hello world"

Under python 3, print is now a function call:

print("hello world")

Solution 4

Same problem, I deleted the .idea and __pycache__ directories in the project directory and everything was fine :)

Solution 5

Just delete .idea folder from your project directory.

Share:
28,348
user3385945
Author by

user3385945

Updated on July 17, 2022

Comments

  • user3385945
    user3385945 almost 2 years

    I started to learn python language, and decided to try out PyCharm IDE, which looks really nice. But, whenever I write print it says "Unresolved reference 'print'". I can run the program, but this red-underline is really annoying. How can I fix this?

  • user3385945
    user3385945 over 10 years
    I'm using python latest version 3.4, and I'm using braces, but still experiencing same error..
  • Henry Florence
    Henry Florence over 10 years
    Installed python versions are very platform dependent, most linuxes and mac os use python 2.x for system functionality. The user can then install python 3.x if required, this means there are multiple versions installed, more info about selecting versions in pycharm, here: stackoverflow.com/questions/13988363/…
  • the911s
    the911s about 10 years
    PyCharm was not resolving open() which is a Python built-in function. This fixed the problem for me. Thanks, I'm sure this saved me a ton of time.
  • Ikon
    Ikon over 7 years
    I can confirm this solution helps even today's version 2016.3. Setting everything right in the project settings and then doing a cache clear helped the IDE get back to correctly identifying basic parts of the language. I am using Pyenv with virtualenv plugin, just to clarify details.
  • Big Ian
    Big Ian almost 4 years
    Worked for about 10 seconds it appears to be a python 2 vs python 3 issue guess they didn't want to keep it up to date :|