Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get pylint to use python 3 in VS code?

I want pylint to use python3 for linting in Visual Studio code on Mac (which has both python 2.7 standard and python 3.6).

I've tried changing the path to the python interpreter as per How can I debug Python3 code in Visual Studio Code, to no avail. I keep getting python2 errors instead of python3 errors.

See example code for the problem.

Is there a way I can get pylint to recognize python3 errors?

like image 346
Krishna Moniz Avatar asked Dec 04 '17 14:12

Krishna Moniz


People also ask

How do I select Python version in VS Code?

To do so, open the Command Palette (Ctrl+Shift+P) and enter Preferences: Open User Settings. Then set python.defaultInterpreterPath , which is in the Python extension section of User Settings, with the appropriate interpreter.

Why Python interpreter is not showing in VS Code?

If VS Code doesn't automatically locate the interpreter you're looking for, refer to Environments - Manually specify an interpreter. You can configure the Python extension through settings. Learn more in the Python Settings reference.

How do I change the Python version in VS Code terminal?

To do so, press CMD + SHIFT + P , type Python, and choose Select Interpreter.


1 Answers

  1. Pick a xx.py in Visual Studio Coce(VSC)
  2. In Status Bar Tap Python 2.7.10 like the [img1]
  3. Choose python 3.x like [img2]
  4. Command+Q quit VSC, then open VSC again

enter image description here

img2

like image 121
Bill Avatar answered Sep 27 '22 16:09

Bill