Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove Python 3 warnings for print statements in Pycharm when using the Python 2 interpreter?

Tags:

python

pycharm

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.


People also ask

How do I ignore warnings in PyCharm?

In the Settings/Preferences dialog ( Ctrl+Alt+S ), select Editor | Inspections. Locate the inspection you want to disable, and clear the checkbox next to it. Apply the changes and close the dialog.

How do I turn on warnings in PyCharm?

Press Ctrl+Alt+S to open the IDE settings and select Editor | Inspections. Select the profile that you want to modify and then choose an inspection from the list. Make sure that it is enabled. From the In All Scopes list, select the scope for which you want to change the severity.

How do I change from python2 to python3 in PyCharm?

Change the Python interpreter in the project settingsPress Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. Expand the list of the available interpreters and click the Show All link. Select the target interpreter.


1 Answers

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

like image 114
afxentios Avatar answered Sep 21 '22 15:09

afxentios