Nidupb
Nidupb

Reputation: 221

Python 3, VS code, and utf-8 is producing an error

I'm using VS Code and the interpreter is Python 3.8.3

When I'm doing the following :

print("é")

I got the following error :

SyntaxError: Non-ASCII character '\xc3' in file

If I change my code for :

# -*- coding: utf-8 -*-
print("é")

It works as expected. I understand that the coding: utf-8 should be useless in python3. It's like despite picking a Python3 interpreter, it's running on Python2. What could be the source of the issue ?

Upvotes: 2

Views: 2126

Answers (1)

Nidupb
Nidupb

Reputation: 221

I found a solution :

  • Make sure the interpreter path in your json file is right
  • Add the following parameter :

    "code-runner.executorMap.python": "python3 -u"

I don't know if it should have been there at the beginning, but it now runs on the correct Python version.

Upvotes: 2

Related Questions