question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot debug using a custom Python interpreter

See original GitHub issue

Likely to be fixed by PR in #8856 - in that issue’s comments it was speculated this issue is caused by a timeout while validating the Python interpreter.

Environment data

  • VS Code version: 1.53.0
  • Extension version (available under the Extensions sidebar): v2021.2.531887795-dev (as suggested in #8856)
  • OS and version: openSUSE Tumbleweed 20210205
  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.18, custom distribution
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): N/A
  • Value of the python.languageServer setting: jedi (but also tried MS and pylance with the same results)

Expected behaviour

Python debug processes work fine

Actual behaviour

I use a custom Python interpreter that takes 2-3 seconds to come up due to its extensive bootstrapping. When trying to start a debug configuration, I always get the error message “The Python path in your debug configuration is invalid.”. The log shows Invalid Python Path ‘/home/XXX/YYY/ZZZ/bin/CUSTOM’.

Up until recently, I was using vscode-python 2019.9.1, which seems to be the latest version that works with my custom interpreter. Now, VSCode January 2021 seems to break compatibility with the older vscode-python:

Debugger Error: The number of constructor arguments in the derived class s must be >= than the number of constructor arguments of its base class.

If I use the custom interpreter to start a debugpy process in another terminal and connect to it with a debug configuration, everything works just fine.

Steps to reproduce:

I can’t distribute the custom interpreter. But it should be rerproducible with vanilla Python if you can introduce a small lag in the bootstrap process.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
karthiknadigcommented, Oct 19, 2021

For anyone else running into this issue here is a work around. It is not ideal, but it will allow you to work with custom pythons that write to stderr.

  1. Find the debug adapter path for debugpy shipped with the extension. It should be <HOME>\.vscode\extensions\ms-python.python-*\pythonfiles\lib\python\debugpy\adapter.
  2. run the debug adapter as a server: python debugpy/adapter --port 5678
  3. Add this configuration to your launch.json:
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "debugServer": 5678  // <---- this is the key, this will get around all the validation and VS Code will talk directly with the debug adapter
        }

You can use other "request": "launch" configurations, as long as you have "debugServer": <port>

0reactions
karthiknadigcommented, Mar 10, 2021

We exit if anything gets written into stderr when getting python info: https://github.com/Microsoft/vscode-python/blob/db8e1e2460e9754ec0672d958789382b6d15c5aa/src/client/pythonEnvironments/info/interpreter.ts#L68

    const result = await shellExec(quoted, 15000);
    if (result.stderr) {
        if (logger) {
            logger.error(`Failed to parse interpreter information for ${argv} stderr: ${result.stderr}`);
        }
        return undefined;
    }

This results in validation failure here https://github.com/Microsoft/vscode-python/blob/48d66bd5b2943f155a9d63a1b951628c15831c1d/src/client/application/diagnostics/checks/invalidPythonPathInDebugger.ts#L88

Which eventually result in the message that you see.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging configurations for Python apps in Visual Studio Code
To use a different interpreter, specify its path instead in the python property of a debug configuration. Alternately, you can use a custom...
Read more >
Cannot select a python interpreter in VScode
I'm having some troubles trying to select a python interpreter in VScode. ... I cannot debug because I get this error messages: cannot...
Read more >
Configure a Python interpreter | PyCharm Documentation
Press Ctrl+Alt+S to open the IDE settings and select Project <project name> | Python Interpreter. · Expand the list of the available interpreters ......
Read more >
sys — System-specific parameters and functions
This module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter.
Read more >
Symbols for mixed-mode Python/C++ debugging
To provide a full debugging experience, the mixed-mode Python debugger in Visual Studio needs debug symbols for the Python interpreter being ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found