40

Project Interpreter in PyCharm's settings for the project "Python 3.6 C:\Anaconda\python.exe"

But in my code I get inspections like "Python version 3.5 does not support a 'F' prefix"

There is no Python3.5 on my system anywhere, I tried to resolve this doing the following:

  • removed the interpreter in pycharm settings, then added it back
  • uninstalled all other python versions, deleted their entries from windows registry etc
  • updated anaconda / conda etc

nothing is working. And anyway why does PyCharm show that the python version is 3.6 when I select it as the project interpreter, but that it is 3.5 in inspections?

Bob
  • 5,809
  • 5
  • 36
  • 53

4 Answers4

76

Go to Settings->Editor->Inspections. There in Python->Code compatibility inspections, you should see that Python 3.5's box is ticked in.

This allows you to choose for which versions of Python your code will be inspected.

Eskapp
  • 3,419
  • 2
  • 22
  • 39
  • 1
    I started getting this error after I created a Jupyter notebook to test my flask API, and let PyCharm install Jupyter. I'm on macos, so I went to PyCharm/Preferences/Editor/Inspections/Python -- Code Compatibility was not checked. I checked it and it actually had 3.7 checked (as of this writing Python 3.7.0b4 is in pre-release.) I did invalidate caches and restart as well. – Ion Freeman May 22 '18 at 12:44
  • 2
    It seems that, unintuitively, 'code compatibility inspection' needs to be checked and the Python versions you don't care about need to be unchecked. https://stackoverflow.com/questions/38588970/python3-syntax-in-pycharm#comment64566081_38589030 – Joshua Chia Nov 06 '18 at 09:16
  • 1
    This issue can also crop up if you disable all Python inspections in Settings by un-ticking the Python language group and then re-enable them later. – DaveL17 Dec 19 '22 at 01:28
7

I totally agree with @Eskapp's answer, but here are a few additions that I had to do.

  1. Press Ctrl + Alt + S OR Command + Option + S To open the Settings
  2. Settings > Editor > Inspections > Python | Code compatibility inspection > Select the version(s) (In my case 3.7 and 3.8 and disselcting 2.7)
  3. Settings > Project: | Project Interpreter > Make sure correct version and interpreter is selected.
  4. File > Invalidate Caches / Restart...
  5. Done.
Machavity
  • 30,841
  • 27
  • 92
  • 100
Vikram Bankar
  • 386
  • 4
  • 4
1

Looks like you have Code Compatibility Inspection enabled. Please check the attached screenshot:

screenshot

0

I often run into this issue due to symlinks. PyCharm apparently caches the interpreter version somewhere internally when you add a new Project interpreter. If that happens to be a symlink, and you later change the symlink to point to another path/interpreter, PyCharm will still think it's the old interpreter. In order to make it check the interpreter version again I need to go to that project interpreter and edit it - e.g. change the path to something else, and then back. It forces PyCharm to re-validate the interpreter and update cached version.

nirvana-msu
  • 3,877
  • 2
  • 19
  • 28