Skip to content
Advertisement

Pycharm is generating language errors for Python version 3.6 although interpreter is 3.9

The language interpreter is set to a Python 3.9 version:

Python 3.9 interpreter

But a Python scratch file is being parsed by some kind of 3.6 interpreter:

Complaint about 3.6 language features

Note that I created in two different scratch files and the same error occurs. Why would this happen and is there a workaround [short of creating an entirely new project from scratch]?

I am on Pycharm Professional 2021.3.1

Update based on answer by @TurePaisson he though maybe the Code is compatible with specific Python were set. That was a shrewd guess – but turns out I have not set that:

enter image description here

enter image description here

Update The following snippet can be used to test python3.6 vs 3.8+

x = (y := 3) + 7 

Advertisement

Answer

Following up on @bad_coder ‘s attempt to fix that will be paraphrased as:

check the Run Configuration for pointing to a different python interpreter than the project level one

That fix worked for me:

  1. Bring up the Run [Context menu] | Edit Configurations

enter image description here

  1. Change the Python interpreter to the appropriate one: Shown below is a case where the interpreter is said to the earlier language level. Go to the dropdown and select a correct [python 3.8+] interpeter.

enter image description here

Advertisement