Kath
Kath

Reputation: 1854

How to start debugging Python 3.6 in Visual Studio Code?

I'm trying to create some script using this IDE but I can't make it work. I installed Python 3.6, added to path (it's visible finally), installed Python extension (from Microsoft I believe).

Then I tried this manual https://code.visualstudio.com/docs/python/environments but I'm stuck on the first step.

When I try the command Select Workspace interpreter I have the following error:

command 'python.setInterpreter' not found

I'm puzzled what it means. Google can't find anything on this issue, only some github pages that don't exist anymore.

And if I try to start debugging it shows:

command 'python.python-debug.startSession' not found

OS: Windows 7 Also I want to test scripts created in virtual environment, maybe it's a reason why it doesn't work but I have no idea how to do it.

UPD: I uninstalled and installed the extension again. I don't see these error but debugging still doesn't work just loading CPU and ignoring any breakpoints.

Upvotes: 1

Views: 10191

Answers (3)

smsarwar
smsarwar

Reputation: 371

One way to tackle this problem in Visual Studio Code is to the downgrade the version of Python extension from Microsoft. It can be very easily done through the Visual Studio Code interface. Locate the installed extension using the extension tab, and right click on the extension. Then You will find an option "Install Another Version...". Click on that and you will find a bunch of versions. Select the one that was published, for example, a month ago. Try to see if it works. If it does not, try with the other (preferably older) ones.

Upvotes: 2

Azmol
Azmol

Reputation: 477

In vscode do the following...

  1. ctrl + shift + p
  2. Select Python: Create Terminal. this should get rid of "command 'python.setInterpreter' not found" problem
  3. ctrl + shift + p
  4. Select Python: Select Interpreter
  5. Select the path to your virtual environment folder. This will now create a .vscode folder in the root directory of your folder and the settings file with "python.pythonPath": "venv\\Scripts\\python.exe" in it
  6. You might get "Linter pylint not installed" notification at the bottom
  7. Run pip install -U pylint
  8. Open a document and you should not see the notification anymore

Upvotes: 0

vtortola
vtortola

Reputation: 35945

It worked for me going into ~/.vscode/extensions/, deleting the extension's folder manually and reinstalling it again.

Upvotes: 2

Related Questions