15

E.g.:

print 'abc'

gets highlighted with a message:

Python version >= 3.0 do not support this syntax.

How to disable that, since I'm on Python 2?

I know about import __future__ but I don't want to use it now.

I've looked under inspections in the settings, but could not find anything relevant.

The Project Interpreter setting for the project is already 2.7.6, and my programs do run correctly (they wouldn't if the interpreter used to run were python 3).

Pycharm Community Edition 2016.3.1, Ubuntu 14.04, python in PATH is Python 2.

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
  • I recently saw a [question](http://stackoverflow.com/questions/41111702/why-am-i-getting-a-syntax-error-in-python-using-eclipse) about a similar problem in Eclipse, which has a setting for the "interpreter" and a separate setting for "grammar." Could there be a separate option for this in PyCharm as well? – TigerhawkT3 Dec 21 '16 at 10:59
  • @TigerhawkT3 if it does, I couldn't find it :-) – Ciro Santilli OurBigBook.com Dec 21 '16 at 11:05
  • From the [link to the interpreter section of the documentation](http://stackoverflow.com/a/41260584/2617068), I get the impression that that's how you set the executable that runs scripts, not necessarily what validation rules it uses when deciding on what warnings to produce. Is it possible to [disable that particular inspection](https://www.jetbrains.com/help/pycharm/2016.3/disabling-and-enabling-inspections.html), perhaps? – TigerhawkT3 Dec 21 '16 at 11:19
  • @TigerhawkT3 yeah, I looked into inspections, but could not find the right one. afxentios did :-) – Ciro Santilli OurBigBook.com Dec 21 '16 at 11:28
  • Figured as much. :) Side note: I was amused to see on that page a warning for "Potentially confusing code constructs - 'with' statement." – TigerhawkT3 Dec 21 '16 at 11:29

2 Answers2

13

I believe what causes this warning is the Editor Inspector and the python version that is set to check.

In Python 2 print is statement, but in Python 3 is a function so it requires parenthesis

Go to Settings > Editor > Inspections. On the Search Field type "Code compatibility inspection" under Python.

Check what python version you have selected on the Options. If you have ticked anything else than 2.7, un-select it and just leave 2.7 as selected.

Editor Inspector Example

afxentios
  • 2,502
  • 2
  • 21
  • 24
1

What you want is changing the project interpreter

EDIT:

This looks to be a bug in older version, try updating to 2016.1.5

Seif
  • 1,058
  • 11
  • 19