Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong Python version in PyCharm's inspections

Tags:

pycharm

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?

like image 386
Bob Avatar asked Apr 13 '18 15:04

Bob


People also ask

How do I switch between Python versions?

Yes, you should be able to switch between python versions. As a standard, it is recommended to use the python3 command or python3. 7 to select a specific version. The py.exe launcher will automatically select the most recent version of Python you've installed.


2 Answers

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.

like image 77
Eskapp Avatar answered Oct 17 '22 11:10

Eskapp


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.
like image 6
Vikram Bankar Avatar answered Oct 17 '22 11:10

Vikram Bankar