microsoft / vscode-python

Python extension for Visual Studio Code
https://aka.ms/pvsc-marketplace
MIT License
4.34k stars 1.19k forks source link

Debugger doesn't start in virtual environment #6493

Closed se16n closed 5 years ago

se16n commented 5 years ago

Environment data

Expected behaviour

After pressing F5 debugger should start with and stop on breakpoint set in current file.

Actual behaviour

When i hit F5 with "Python: Current file" template in virtual environment debugger doesn't start, program just executing.

Same actions works if i run debugging with system-wide python i.e without venv.

Venv is in the root of project folder.

Steps to reproduce:

  1. Create virtual environment in your project root
  2. Press F5 with profile "Python: Current file".

Logs

Launch.json

{
    // 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: Remote Attach",
            "type": "python",
            "request": "attach",
            "port": 5678,
            "host": "localhost",
            "pathMappings": [
                {
                    "localRoot": "${workspaceFolder}",
                    "remoteRoot": "."
                }
            ]
        },
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        }
    ]
}

Setting.json

{
    "python.pythonPath": "E:\\Projects\\TgBot\\Scripts\\python.exe"
}

--log-folder

I00000.000: Windows-7-6.1.7601-SP1 AMD64
            CPython 3.7.2 (32-bit)
            ptvsd 4.2.10

I00000.015: main(['c:\\Users\\User\\.vscode\\extensions\\ms-python.python-2019.6.22090\\pythonFiles\\ptvsd_launcher.py', '--client', '--log-dir', 'E:\\Projects\\TgBot', '--host', 'localhost', '--port', '51008', 'e:\\Projects\\TgBot\\Client.py'])

I00000.015: sys.argv after parsing: ['c:\\Users\\User\\.vscode\\extensions\\ms-python.python-2019.6.22090\\pythonFiles\\ptvsd_launcher.py']

D00000.015: sys.prefix: ('E:\\Projects\\TgBot',)

D00000.015: sys.base_prefix: C:\Users\User\AppData\Local\Programs\Python\Python37-32

D00000.015: site.getusersitepackages(): C:\Users\User\AppData\Roaming\Python\Python37\site-packages

D00000.015: site.getsitepackages(): ['E:\\Projects\\TgBot', 'E:\\Projects\\TgBot\\lib\\site-packages']

D00000.015: Folder with "site-packages" in sys.path: E:\Projects\TgBot\lib\site-packages

D00000.015: sysconfig platlib: E:\Projects\TgBot\Lib\site-packages

D00000.015: sysconfig platstdlib: E:\Projects\TgBot\Lib

D00000.015: sysconfig purelib: E:\Projects\TgBot\Lib\site-packages

D00000.015: sysconfig stdlib: C:\Users\User\AppData\Local\Programs\Python\Python37-32\Lib

D00000.015: os dir: C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib

D00000.015: threading dir: C:\Users\User\AppData\Local\Programs\Python\Python37-32\lib

D00000.015: sys.argv after patching: ['e:\\Projects\\TgBot\\Client.py']

D00000.015: Installing pydevd hooks.

D00000.015: Monkey-patching multiprocess functions.

D00000.015: pydevd.settrace()

D00000.015: Starting client daemon on ('localhost', 51008).

D00001.014: Closing daemon after single session

D00001.014: Stopping daemon.

E00001.014: Exception escaped from start_client

            Traceback (most recent call last):
              File "c:\Users\User\.vscode\extensions\ms-python.python-2019.6.22090\pythonFiles\lib\python\ptvsd\log.py", line 110, in g
                return f(*args, **kwargs)
              File "c:\Users\User\.vscode\extensions\ms-python.python-2019.6.22090\pythonFiles\lib\python\ptvsd\pydevd_hooks.py", line 74, in start_client
                sock, start_session = daemon.start_client((host, port))
              File "c:\Users\User\.vscode\extensions\ms-python.python-2019.6.22090\pythonFiles\lib\python\ptvsd\daemon.py", line 217, in start_client
                connect(client, addr)
              File "c:\Users\User\.vscode\extensions\ms-python.python-2019.6.22090\pythonFiles\lib\python\ptvsd\socket.py", line 197, in connect
                sock.connect(addr)
            ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

D00001.014: Handling atexit

D00001.014: Stopping daemon.
karthiknadig commented 5 years ago

@DonJayamanne This looks like the python extension is not creating or unable to create the server socket that debugger connects back to, in the launch scenario. This is an extension issue as far as I can tell.

DonJayamanne commented 5 years ago

Venv is in the root of project folder.

Closing this as debugging Python code with the Python environment as the root directory of the project is not a supported scenario.