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:
- Python 2: use
raw_input - Python 3: use
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
- Python:
3.8.2 - PyCharm:
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
inputfromsix(https://six.readthedocs.io/#module-six.moves).