0
votes

I'm attempting to debug a simple python file. The test.py file just contains the text print("hello"). When I select Run->Start Debugging I get a modal dialog with the following text:

h.toLowerCase is not a function

When I open the config I see:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "simple"
        }
    ]
}

Here's the results of navigating to Help->About->Copy.

Version: 1.51.0 (user setup) Commit: fcac248b077b55bae4ba5bab613fd6e9156c2f0c Date: 2020-11-05T18:18:23.642Z Electron: 9.3.3 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.19042

If I start a command window, I can type python or pip, so those things are in my path.

Python --version generates
3.9.0

VS Code extensions shows that I have the following extensions installed.

Python v2020.10.332292344 Python for VSCode 0.2.3

If I right click in the python file and click run python in console. It works ok. I see the text "Hello" in the console.

2
Have you executed the command: Python: Select InterpreterrioV8
Can you break down how I'd do that? In the lower left corner of VSC, it says Python 3.9.0 64 bit error 0 warning 0 Python Current File (t2)user3112728
Select language mode in lower right is saying python.user3112728
Why would a javascript function be getting called by the python interpreteruser3112728
I've tried uninstalling and reinstalling VSCode and Python to no effect on this box.user3112728

2 Answers

0
votes
{
    "name": "Python",
    "type": "python",
    "pythonPath":"${config.python.pythonPath}", 
    "request": "launch",
    "stopOnEntry": true,
    "console": "none",
    "program": "${file}",
    "cwd": "${workspaceRoot}",
    "debugOptions": [
        "WaitOnAbnormalExit",
        "WaitOnNormalExit",
        "RedirectOutput"
    ],
    "env": {"name":"value"}
}
0
votes

Ok, figured this out. This article was helpful.

https://code.visualstudio.com/docs/python/debugging

There's an optional key called console. Possible values: internalConsole, externalTerminal or the default integratedTerminal. Temporarily, set this key to externalTerminal. Run the F5 or Run->Start Debug again. You'll get an error message that looks like this.

Traceback (most recent call last):
  File "...\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "...\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "...\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "...\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "...\.vscode\extensions\ms-python.python-2020.10.332292344\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 267, in run_file
    runpy.run_path(options.target, run_name=compat.force_str("__main__"))
  File "...\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 267, in run_path
    code, fname = _get_code_from_file(run_name, path_name)
  File "...\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 242, in _get_code_from_file
    code = compile(f.read(), fname, 'exec')
  File "...\python\.vscode\launch.json", line 2
    // Use IntelliSense to learn about possible attributes.
    ^
SyntaxError: invalid syntax
Press any key to continue . . .

The error message points out that it got stuck on the Intellisense comment. As a developer, comments are typically a good thing. But this is clearly a problem in the templated launch.json file. If you remove the comments and set the console key to internalConsole, things seem to work.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "simple",
            "console": "internalConsole"
        }
    ]
}