PyCharm Unresolved reference 'print'

PythonPycharm

Python Problem Overview


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?

Python Solutions


Solution 1 - Python

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 - Python

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 - Python

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 - Python

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

Solution 5 - Python

Just delete .idea folder from your project directory.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3385945View Question on Stackoverflow
Solution 1 - PythonDaniel KView Answer on Stackoverflow
Solution 2 - PythonfIwJlxSzApHEZIlView Answer on Stackoverflow
Solution 3 - PythonHenry FlorenceView Answer on Stackoverflow
Solution 4 - PythonOmar Cusma FaitView Answer on Stackoverflow
Solution 5 - PythonJ AView Answer on Stackoverflow