I have a Python module that can be run with both Python 2 and Python 3. At some point, the module takes a user input. How it does so depends on the Python major version:
raw_input
input
My IDE is PyCharm, and my project interpreter is Python 3.8
. PyCharm inspects an unresolved reference error on raw_input
.
Besides a # noinspection PyUnresolvedReferences
tag, how can I get PyCharm not to complain about raw_input
? Is there some setting I can enable?
Sample Code
#!/usr/bin/python
import sys
if sys.version_info[0] > 2:
some_input = input("Please give input: ")
else:
some_input = raw_input("Please give input: ")
print("input: {}".format(some_input))
What I see on my screen:
Versions
3.8.2
CE 2019.3.1
My PyCharm has Code compatibility inspection
enabled for Python 2.7
, 3.6
, 3.7
, and 3.8
.
Environment checks are not supported in PyCharm, consider using input
from six
(https://six.readthedocs.io/#module-six.moves).