Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debugger times out when "qt":"auto" is used with ArcGIS Python #362

Closed
eykamp opened this issue Aug 11, 2020 · 30 comments
Closed

Debugger times out when "qt":"auto" is used with ArcGIS Python #362

eykamp opened this issue Aug 11, 2020 · 30 comments
Assignees
Labels
bug Something isn't working

Comments

@eykamp
Copy link

eykamp commented Aug 11, 2020

Environment data

  • PTVSD version: XXX <-- Not sure, how do I tell?
  • OS and version: Win 10 Enterprise, v. 1709
  • Python version (& distribution if applicable, e.g. Anaconda): Python 3.6.9 , Anaconda (installed by ArcGis)
  • Using VS Code or Visual Studio: VS Code 1.47.3

Actual behavior

When firing up the debugger (F5) even a simple one-line script (print("hello")), I get the dreaded "timed out waiting for debuggee to spawn" dialog. I can run the script using the green triangle with the same version/environment, and if I select a different version of Python, the debugger works fine.

Everything consistently worked for months until this morning when VSCode updated to the June version, and debugging stopped working.

Expected behavior

Debugging should work.

Steps to reproduce:

Press F5 to debug current program.

I've read some of the past cases for this issue, and followed some of the suggestions, but they didn't really seem relevant. I'm not even sure this is a ptvsd issue, but all searches on the error message led me here.

@int19h int19h transferred this issue from microsoft/ptvsd Aug 11, 2020
@int19h
Copy link
Contributor

int19h commented Aug 11, 2020

What's the command line like in the terminal?

If you're using "console": "internalConsole" in launch.json, change to "console": "integratedTerminal" and try like that.

@eykamp
Copy link
Author

eykamp commented Aug 11, 2020

cd c:\dev\NESDI && cmd /C ""C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\python.exe" c:\Users\eykampC.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\launcher 49258 -- c:\dev\NESDI\delme.py "

@int19h
Copy link
Contributor

int19h commented Aug 11, 2020

Those old issues from the ptvsd repo shouldn't be relevant here. But it probably does have something to do with ArcGIS Python. We'll need the logs to figure that out, though. Can you please add this:

"logToFile": true

to your debug config, and then look for debugpy*.log in c:\Users\eykampC.vscode\extensions\ms-python.python-2020.7.96456?

@eykamp
Copy link
Author

eykamp commented Aug 11, 2020

I figured those old issues were, well, old, but I looked through them just to make sure.

Here are the logs.

debugger.log:

0 Starting Session:
{
    "name": "Python: Current File (Integrated Terminal)",
    "type": "python",
    "request": "launch",
    "program": "c:\\dev\\PIMS - dev\\delme2.py",
    "logToFile": true,
    "console": "integratedTerminal",
    "pythonPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe",
    "cwd": "c:\\dev\\PIMS - dev",
    "envFile": "c:\\dev\\PIMS - dev/.env",
    "env": {
        "PYTHONIOENCODING": "UTF-8",
        "PYTHONUNBUFFERED": "1"
    },
    "stopOnEntry": false,
    "showReturnValue": true,
    "internalConsoleOptions": "neverOpen",
    "debugOptions": [
        "ShowReturnValue",
        "FixFilePathCase"
    ],
    "justMyCode": true,
    "workspaceFolder": "c:\\dev\\PIMS - dev"
}
258 Client --> Adapter:
{
    "command": "initialize",
    "arguments": {
        "clientID": "vscode",
        "clientName": "Visual Studio Code",
        "adapterID": "python",
        "pathFormat": "path",
        "linesStartAt1": true,
        "columnsStartAt1": true,
        "supportsVariableType": true,
        "supportsVariablePaging": true,
        "supportsRunInTerminalRequest": true,
        "locale": "en-us",
        "supportsProgressReporting": true
    },
    "type": "request",
    "seq": 1
}
4638 Client <-- Adapter:
{
    "seq": 1,
    "type": "event",
    "event": "output",
    "body": {
        "category": "telemetry",
        "output": "ptvsd",
        "data": {
            "packageVersion": "1.0.0b12"
        }
    }
}
4642 Client <-- Adapter:
{
    "seq": 2,
    "type": "event",
    "event": "output",
    "body": {
        "category": "telemetry",
        "output": "debugpy",
        "data": {
            "packageVersion": "1.0.0b12"
        }
    }
}
4649 Client <-- Adapter:
{
    "seq": 3,
    "type": "response",
    "request_seq": 1,
    "success": true,
    "command": "initialize",
    "body": {
        "supportsCompletionsRequest": true,
        "supportsConditionalBreakpoints": true,
        "supportsConfigurationDoneRequest": true,
        "supportsDebuggerProperties": true,
        "supportsDelayedStackTraceLoading": true,
        "supportsEvaluateForHovers": true,
        "supportsExceptionInfoRequest": true,
        "supportsExceptionOptions": true,
        "supportsHitConditionalBreakpoints": true,
        "supportsLogPoints": true,
        "supportsModulesRequest": true,
        "supportsSetExpression": true,
        "supportsSetVariable": true,
        "supportsValueFormattingOptions": true,
        "supportsTerminateDebuggee": true,
        "supportsGotoTargetsRequest": true,
        "exceptionBreakpointFilters": [
            {
                "filter": "raised",
                "label": "Raised Exceptions",
                "default": false
            },
            {
                "filter": "uncaught",
                "label": "Uncaught Exceptions",
                "default": true
            }
        ]
    }
}
4667 Client --> Adapter:
{
    "command": "launch",
    "arguments": {
        "name": "Python: Current File (Integrated Terminal)",
        "type": "python",
        "request": "launch",
        "program": "c:\\dev\\PIMS - dev\\delme2.py",
        "logToFile": true,
        "console": "integratedTerminal",
        "pythonPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe",
        "cwd": "c:\\dev\\PIMS - dev",
        "envFile": "c:\\dev\\PIMS - dev/.env",
        "env": {
            "PYTHONIOENCODING": "UTF-8",
            "PYTHONUNBUFFERED": "1"
        },
        "stopOnEntry": false,
        "showReturnValue": true,
        "internalConsoleOptions": "neverOpen",
        "debugOptions": [
            "ShowReturnValue",
            "FixFilePathCase"
        ],
        "justMyCode": true,
        "workspaceFolder": "c:\\dev\\PIMS - dev",
        "__sessionId": "c9f7860a-c229-4c77-8020-65701fb5bea0"
    },
    "type": "request",
    "seq": 2
}
4697 Client <-- Adapter:
{
    "seq": 4,
    "type": "request",
    "command": "runInTerminal",
    "arguments": {
        "kind": "integrated",
        "title": "Python Debug Console",
        "args": [
            "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe",
            "c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456\\pythonFiles\\lib\\python\\debugpy\\launcher",
            "63738",
            "--",
            "c:\\dev\\PIMS - dev\\delme2.py"
        ],
        "env": {
            "DEBUGPY_LOG_DIR": "c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456"
        },
        "cwd": "c:\\dev\\PIMS - dev"
    }
}
8439 Client --> Adapter:
{
    "type": "response",
    "seq": 3,
    "command": "runInTerminal",
    "request_seq": 4,
    "success": true,
    "body": {
        "shellProcessId": 26704
    }
}
28071 Client <-- Adapter:
{
    "seq": 5,
    "type": "response",
    "request_seq": 2,
    "success": false,
    "command": "launch",
    "message": "Timed out waiting for debuggee to spawn"
}
28085 Client --> Adapter:
{
    "command": "disconnect",
    "arguments": {
        "restart": false
    },
    "type": "request",
    "seq": 4
}
28214 Client <-- Adapter:
{
    "seq": 6,
    "type": "event",
    "event": "exited",
    "body": {
        "exitCode": 1
    }
}
28219 Client <-- Adapter:
{
    "seq": 7,
    "type": "event",
    "event": "terminated"
}
28221 Client <-- Adapter:
{
    "seq": 8,
    "type": "response",
    "request_seq": 4,
    "success": true,
    "command": "disconnect"
}
28260 Stopping Session
30751 Error:
{}
30767 Exit:
Exit-Code: 1
Signal: none

adapter.log:

I+00000.359: Windows-10-10.0.16299-SP0 AMD64
             CPython 3.6.9 (64-bit)
             debugpy 1.0.0b12

I+00000.390: debugpy.adapter startup environment:
             
             System paths:
                 sys.prefix: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                 sys.base_prefix: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                 sys.real_prefix: <missing>
                 site.getsitepackages(): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                                         C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\site-packages
                 site.getusersitepackages(): C:\Users\eykampC\AppData\Roaming\Python\Python36\site-packages
                 sys.path (site-packages): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\site-packages
                                           C:\Users\eykampC\AppData\Roaming\Python\Python36\site-packages
                 sysconfig.get_path('stdlib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib
                 sysconfig.get_path('platstdlib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib
                 sysconfig.get_path('purelib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib\site-packages
                 sysconfig.get_path('platlib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib\site-packages
                 sysconfig.get_path('include'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Include
                 sysconfig.get_path('scripts'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Scripts
                 sysconfig.get_path('data'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                 os.__file__: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\os.py
                 threading.__file__: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\threading.py

I+00000.421: Listening for incoming Client connections on 127.0.0.1:63736...

I+00000.437: Connecting to client over stdio...

D+00000.453: Starting message loop for channel Client[1]

D+00000.453: Client[1] <-- {
                 "seq": 1,
                 "type": "event",
                 "event": "output",
                 "body": {
                     "category": "telemetry",
                     "output": "ptvsd",
                     "data": {
                         "packageVersion": "1.0.0b12"
                     }
                 }
             }

D+00000.453: Client[1] <-- {
                 "seq": 2,
                 "type": "event",
                 "event": "output",
                 "body": {
                     "category": "telemetry",
                     "output": "debugpy",
                     "data": {
                         "packageVersion": "1.0.0b12"
                     }
                 }
             }

D+00000.453: Client[1] --> {
                 "seq": 1,
                 "type": "request",
                 "command": "initialize",
                 "arguments": {
                     "clientID": "vscode",
                     "clientName": "Visual Studio Code",
                     "adapterID": "python",
                     "pathFormat": "path",
                     "linesStartAt1": true,
                     "columnsStartAt1": true,
                     "supportsVariableType": true,
                     "supportsVariablePaging": true,
                     "supportsRunInTerminalRequest": true,
                     "locale": "en-us",
                     "supportsProgressReporting": true
                 }
             }

D+00000.453: /handling #1 request "initialize" from Client[1]/
             Capabilities: {
                 "supportsVariableType": true,
                 "supportsVariablePaging": true,
                 "supportsRunInTerminalRequest": true,
                 "supportsMemoryReferences": false
             }

D+00000.453: /handling #1 request "initialize" from Client[1]/
             Expectations: {
                 "locale": "en-us",
                 "linesStartAt1": true,
                 "columnsStartAt1": true,
                 "pathFormat": "path"
             }

D+00000.468: /handling #1 request "initialize" from Client[1]/
             Client[1] <-- {
                 "seq": 3,
                 "type": "response",
                 "request_seq": 1,
                 "success": true,
                 "command": "initialize",
                 "body": {
                     "supportsCompletionsRequest": true,
                     "supportsConditionalBreakpoints": true,
                     "supportsConfigurationDoneRequest": true,
                     "supportsDebuggerProperties": true,
                     "supportsDelayedStackTraceLoading": true,
                     "supportsEvaluateForHovers": true,
                     "supportsExceptionInfoRequest": true,
                     "supportsExceptionOptions": true,
                     "supportsHitConditionalBreakpoints": true,
                     "supportsLogPoints": true,
                     "supportsModulesRequest": true,
                     "supportsSetExpression": true,
                     "supportsSetVariable": true,
                     "supportsValueFormattingOptions": true,
                     "supportsTerminateDebuggee": true,
                     "supportsGotoTargetsRequest": true,
                     "exceptionBreakpointFilters": [
                         {
                             "filter": "raised",
                             "label": "Raised Exceptions",
                             "default": false
                         },
                         {
                             "filter": "uncaught",
                             "label": "Uncaught Exceptions",
                             "default": true
                         }
                     ]
                 }
             }

D+00000.484: Client[1] --> {
                 "seq": 2,
                 "type": "request",
                 "command": "launch",
                 "arguments": {
                     "name": "Python: Current File (Integrated Terminal)",
                     "type": "python",
                     "request": "launch",
                     "program": "c:\\dev\\PIMS - dev\\delme2.py",
                     "logToFile": true,
                     "console": "integratedTerminal",
                     "pythonPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe",
                     "cwd": "c:\\dev\\PIMS - dev",
                     "envFile": "c:\\dev\\PIMS - dev/.env",
                     "env": {
                         "PYTHONIOENCODING": "UTF-8",
                         "PYTHONUNBUFFERED": "1"
                     },
                     "stopOnEntry": false,
                     "showReturnValue": true,
                     "internalConsoleOptions": "neverOpen",
                     "debugOptions": [
                         "ShowReturnValue",
                         "FixFilePathCase"
                     ],
                     "justMyCode": true,
                     "workspaceFolder": "c:\\dev\\PIMS - dev",
                     "__sessionId": "c9f7860a-c229-4c77-8020-65701fb5bea0"
                 }
             }

I+00000.484: /handling #2 request "launch" from Client[1]/
             Listening for incoming Server connections on 127.0.0.1:63737...

I+00000.500: /handling #2 request "launch" from Client[1]/
             Listening for incoming Launcher connections on 127.0.0.1:63738...

I+00000.515: /handling #2 request "launch" from Client[1]/
             Session[1] spawning launcher via "runInTerminal" request.

D+00000.515: /handling #2 request "launch" from Client[1]/
             Client[1] <-- {
                 "seq": 4,
                 "type": "request",
                 "command": "runInTerminal",
                 "arguments": {
                     "kind": "integrated",
                     "title": "Python Debug Console",
                     "args": [
                         "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe",
                         "c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456\\pythonFiles\\lib\\python\\debugpy\\launcher",
                         "63738",
                         "--",
                         "c:\\dev\\PIMS - dev\\delme2.py"
                     ],
                     "env": {
                         "DEBUGPY_LOG_DIR": "c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456"
                     },
                     "cwd": "c:\\dev\\PIMS - dev"
                 }
             }

D+00004.250: Client[1] --> {
                 "seq": 3,
                 "type": "response",
                 "request_seq": 4,
                 "success": true,
                 "command": "runInTerminal",
                 "body": {
                     "shellProcessId": 26704
                 }
             }

I+00008.562: Accepted incoming Launcher connection from 127.0.0.1:63762.

D+00008.562: Starting message loop for channel Launcher[1]

D+00008.562: /handling #2 request "launch" from Client[1]/
             Launcher[1] <-- {
                 "seq": 1,
                 "type": "request",
                 "command": "launch",
                 "arguments": {
                     "name": "Python: Current File (Integrated Terminal)",
                     "type": "python",
                     "request": "launch",
                     "program": "c:\\dev\\PIMS - dev\\delme2.py",
                     "logToFile": true,
                     "console": "integratedTerminal",
                     "pythonPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe",
                     "cwd": "c:\\dev\\PIMS - dev",
                     "envFile": "c:\\dev\\PIMS - dev/.env",
                     "env": {
                         "PYTHONIOENCODING": "UTF-8",
                         "PYTHONUNBUFFERED": "1"
                     },
                     "stopOnEntry": false,
                     "showReturnValue": true,
                     "internalConsoleOptions": "neverOpen",
                     "debugOptions": [
                         "ShowReturnValue",
                         "FixFilePathCase"
                     ],
                     "justMyCode": true,
                     "workspaceFolder": "c:\\dev\\PIMS - dev",
                     "__sessionId": "c9f7860a-c229-4c77-8020-65701fb5bea0",
                     "pythonArgs": [],
                     "processName": "c:\\dev\\PIMS - dev\\delme2.py",
                     "port": 63737,
                     "adapterAccessToken": "64123f9f109fb4c0d3243e365fd401c6b6b24c019445608c6c15552c8f25e6a0"
                 }
             }

D+00008.812: Launcher[1] --> {
                 "seq": 1,
                 "type": "event",
                 "event": "process",
                 "body": {
                     "startMethod": "launch",
                     "isLocalProcess": true,
                     "systemProcessId": 27492,
                     "name": "c:\\dev\\PIMS - dev\\delme2.py",
                     "pointerSize": 64
                 }
             }

D+00008.812: Launcher[1] --> {
                 "seq": 2,
                 "type": "response",
                 "request_seq": 1,
                 "success": true,
                 "command": "launch"
             }

D+00008.828: /handling #1 event "process" from Launcher[1]/
             Propagation deferred.

I+00008.828: /handling #2 request "launch" from Client[1]/
             Session[1] waiting for connection from debug server...

I+00023.828: All debug servers disconnected; waiting for remaining sessions...

E+00023.875: /handling #2 request "launch" from Client[1]/
             Traceback (most recent call last):
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\common\messaging.py", line 1062, in __init__
                 raise self
             debugpy.common.messaging.MessageHandlingError: Timed out waiting for debuggee to spawn
             
             Stack where logged:
               File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\threading.py", line 884, in _bootstrap
                 self._bootstrap_inner()
               File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\threading.py", line 916, in _bootstrap_inner
                 self.run()
               File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\threading.py", line 864, in run
                 self._target(*self._args, **self._kwargs)
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\common\messaging.py", line 1504, in _run_handlers
                 handler()
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\common\messaging.py", line 747, in _handle
                 result = handler(self)
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\adapter\components.py", line 95, in lock_and_handle
                 return f(self, message)
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\adapter\clients.py", line 187, in handle
                 f(self, request)
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\adapter\clients.py", line 360, in launch_request
                 sudo,
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\adapter\launchers.py", line 192, in spawn_debuggee
                 raise start_request.cant_handle("Timed out waiting for debuggee to spawn")
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\common\messaging.py", line 560, in cant_handle
                 return self.error(MessageHandlingError, *args, **kwargs)
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\common\messaging.py", line 546, in error
                 exc = exc_type(reason, self, silent)  # will log it
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\common\messaging.py", line 1064, in __init__
                 log.swallow_exception()
               File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\common\log.py", line 215, in swallow_exception
                 _exception(format_string, *args, **kwargs)
             

D+00023.890: /handling #2 request "launch" from Client[1]/
             Client[1] <-- {
                 "seq": 5,
                 "type": "response",
                 "request_seq": 2,
                 "success": false,
                 "command": "launch",
                 "message": "Timed out waiting for debuggee to spawn"
             }

D+00023.906: Client[1] --> {
                 "seq": 4,
                 "type": "request",
                 "command": "disconnect",
                 "arguments": {
                     "restart": false
                 }
             }

E+00023.968: /handling #2 request "launch" from Client[1]/
             Handler 'Client._start_message_handler.<locals>.handle' (file 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456\\pythonFiles\\lib\\python\\debugpy\\adapter/../..\\debugpy\\adapter\\components.py', line 171)
             couldn't handle #2 request "launch" from Client[1]:
             Timed out waiting for debuggee to spawn

I+00023.968: /handling #4 request "disconnect" from Client[1]/
             client requested "disconnect"; finalizing Session[1].

D+00023.968: /handling #4 request "disconnect" from Client[1]/
             Launcher[1] <-- {
                 "seq": 2,
                 "type": "request",
                 "command": "terminate"
             }

D+00023.984: Launcher[1] --> {
                 "seq": 3,
                 "type": "response",
                 "request_seq": 2,
                 "success": true,
                 "command": "terminate"
             }

I+00023.984: /handling #4 request "disconnect" from Client[1]/
             Session[1] waiting for Launcher[1] to disconnect...

D+00024.015: Launcher[1] --> {
                 "seq": 4,
                 "type": "event",
                 "event": "exited",
                 "body": {
                     "exitCode": 1
                 }
             }

D+00024.031: Launcher[1] --> {
                 "seq": 5,
                 "type": "event",
                 "event": "terminated"
             }

D+00024.031: /handling #5 event "terminated" from Launcher[1]/
             Client[1] <-- {
                 "seq": 6,
                 "type": "event",
                 "event": "exited",
                 "body": {
                     "exitCode": 1
                 }
             }

D+00024.031: /handling #5 event "terminated" from Launcher[1]/
             Closing Launcher[1] message stream

D+00024.031: Exiting message loop for channel Launcher[1]: [WinError 10038] An operation was attempted on something that is not a socket

D+00024.031: /handling #4 request "disconnect" from Client[1]/
             Client[1] <-- {
                 "seq": 7,
                 "type": "event",
                 "event": "terminated"
             }

I+00024.031: /handling #4 request "disconnect" from Client[1]/
             Session[1] finalized.

D+00024.031: /handling #4 request "disconnect" from Client[1]/
             Client[1] <-- {
                 "seq": 8,
                 "type": "response",
                 "request_seq": 4,
                 "success": true,
                 "command": "disconnect"
             }

launcher.log:

I+00000.234: Windows-10-10.0.16299-SP0 AMD64
             CPython 3.6.9 (64-bit)
             debugpy 1.0.0b12

I+00000.250: debugpy.launcher startup environment:
             
             System paths:
                 sys.prefix: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                 sys.base_prefix: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                 sys.real_prefix: <missing>
                 site.getsitepackages(): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                                         C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\site-packages
                 site.getusersitepackages(): C:\Users\eykampC\AppData\Roaming\Python\Python36\site-packages
                 sys.path (site-packages): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\site-packages
                                           C:\Users\eykampC\AppData\Roaming\Python\Python36\site-packages
                 sysconfig.get_path('stdlib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib
                 sysconfig.get_path('platstdlib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib
                 sysconfig.get_path('purelib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib\site-packages
                 sysconfig.get_path('platlib'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Lib\site-packages
                 sysconfig.get_path('include'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Include
                 sysconfig.get_path('scripts'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\Scripts
                 sysconfig.get_path('data'): C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev
                 os.__file__: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\os.py
                 threading.__file__: C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\lib\threading.py

I+00000.250: sys.argv before parsing: ['c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456\\pythonFiles\\lib\\python\\debugpy\\launcher', '63738', '--', 'c:\\dev\\PIMS - dev\\delme2.py']

I+00000.250: sys.argv after patching: ['c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456\\pythonFiles\\lib\\python\\debugpy\\launcher', 'c:\\dev\\PIMS - dev\\delme2.py']

I+00000.296: Connecting to adapter at 127.0.0.1:63738

D+00000.312: Starting message loop for channel Adapter

D+00000.328: Adapter --> {
                 "seq": 1,
                 "type": "request",
                 "command": "launch",
                 "arguments": {
                     "name": "Python: Current File (Integrated Terminal)",
                     "type": "python",
                     "request": "launch",
                     "program": "c:\\dev\\PIMS - dev\\delme2.py",
                     "logToFile": true,
                     "console": "integratedTerminal",
                     "pythonPath": "C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe",
                     "cwd": "c:\\dev\\PIMS - dev",
                     "envFile": "c:\\dev\\PIMS - dev/.env",
                     "env": {
                         "PYTHONIOENCODING": "UTF-8",
                         "PYTHONUNBUFFERED": "1"
                     },
                     "stopOnEntry": false,
                     "showReturnValue": true,
                     "internalConsoleOptions": "neverOpen",
                     "debugOptions": [
                         "ShowReturnValue",
                         "FixFilePathCase"
                     ],
                     "justMyCode": true,
                     "workspaceFolder": "c:\\dev\\PIMS - dev",
                     "__sessionId": "c9f7860a-c229-4c77-8020-65701fb5bea0",
                     "pythonArgs": [],
                     "processName": "c:\\dev\\PIMS - dev\\delme2.py",
                     "port": 63737,
                     "adapterAccessToken": "64123f9f109fb4c0d3243e365fd401c6b6b24c019445608c6c15552c8f25e6a0"
                 }
             }

I+00000.328: /handling #1 request "launch" from Adapter/
             Spawning debuggee process:
             
             Command line: ['C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe', 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456\\pythonFiles\\lib\\python\\debugpy', '--connect', '127.0.0.1:63737', '--configure-qt', 'auto', '--adapter-access-token', '64123f9f109fb4c0d3243e365fd401c6b6b24c019445608c6c15552c8f25e6a0', 'c:\\dev\\PIMS - dev\\delme2.py']
             
             Environment variables: {'ADSKFLEX_LICENSE_FILE': '@DENAPP27.amr.ch2m.com;@HUKAPP21.ext.ch2m.com', 'ADSK_CASCADING_OVERRIDE': '0', 'AGSDESKTOPJAVA': 'C:\\Program Files (x86)\\ArcGIS\\Desktop10.6\\', 'ALLUSERSPROFILE': 'C:\\ProgramData', 'APPDATA': 'C:\\Users\\eykampC\\AppData\\Roaming', 'CH2MLIC': '\\\\DC1MAN98\\APPS\\eat\\Lic\\DAG_CH2M.Lic', 'CH2M_APPS': '\\\\DC1MAN98\\APPS', 'CH2M_NETWORKSTATUS': '2', 'CH2M_OFFICE': 'USLAS0-VPN-Internal', 'CH2M_SOFTWARE': '\\\\DC1MAN98\\SOFTWARE', 'CH2M_SQL': 'BRIGGSDALE', 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files', 'COMMONPROGRAMFILES(X86)': 'C:\\Program Files (x86)\\Common Files', 'COMMONPROGRAMW6432': 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'USPDX1L5T6GHR2', 'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe', 'CONDA_DEFAULT_ENV': 'root', 'CONDA_PREFIX': 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python', 'CONDA_PS1_BACKUP': '$P$G', 'DEBUGPY_LOG_DIR': 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456', 'DEFLOGDIR': 'C:\\ProgramData\\McAfee\\Endpoint Security\\Logs', 'FLEXLM_TIMEOUT': '2000000', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Users\\eykampC', 'LMS': '1.0.171', 'LM_PROJECT': 'T3R2D2PT5', 'LOCALAPPDATA': 'C:\\Users\\eykampC\\AppData\\Local', 'LOGONSERVER': '\\\\USQTS0-INF004', 'NUMBER_OF_PROCESSORS': '12', 'ONEDRIVE': 'C:\\Users\\eykampC\\OneDrive', 'ONEDRIVECONSUMER': 'C:\\Users\\eykampC\\OneDrive', 'ORIGINAL_XDG_CURRENT_DESKTOP': 'undefined', 'OS': 'Windows_NT', 'PATH': 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\Library\\bin;C:\\Program Files\\ArcGIS\\Pro\\bin;C:\\Program Files\\ArcGIS\\Pro\\bin\\Python;C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\Library\\mingw-w64\\bin;C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\Library\\usr\\bin;C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\Library\\bin;C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\Scripts;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\PuTTY\\;C:\\Program Files\\Git\\cmd;C:\\Utils;C:\\Program Files\\nodejs\\;C:\\Program Files (x86)\\Yarn\\bin\\;C:\\Program Files\\OpenSSL-Win64\\bin;C:\\msys64\\mingw64\\bin_xxx;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Users\\eykampC\\AppData\\Local\\Programs\\Python\\Python37\\Scripts\\;C:\\Users\\eykampC\\AppData\\Local\\Programs\\Python\\Python37\\;C:\\Users\\eykampC\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\eykampC\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\eykampC\\AppData\\Local\\Pandoc\\;;C:\\Users\\eykampC\\AppData\\Roaming\\npm;C:\\Users\\eykampC\\AppData\\Local\\Yarn\\bin;C:\\Program Files\\Intel\\WiFi\\bin\\;C:\\Program Files\\Common Files\\Intel\\WirelessCommon\\;C:\\Users\\eykampC\\AppData\\Local\\Programs\\Azure Data Studio\\bin', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC', 'PROCESSOR_ARCHITECTURE': 'AMD64', 'PROCESSOR_IDENTIFIER': 'Intel64 Family 6 Model 158 Stepping 10, GenuineIntel', 'PROCESSOR_LEVEL': '6', 'PROCESSOR_REVISION': '9e0a', 'PROGRAMDATA': 'C:\\ProgramData', 'PROGRAMFILES': 'C:\\Program Files', 'PROGRAMFILES(X86)': 'C:\\Program Files (x86)', 'PROGRAMW6432': 'C:\\Program Files', 'PROMPT': '(root) $P$G', 'PSMODULEPATH': 'C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules', 'PUBLIC': 'C:\\Users\\Public', 'SESSIONNAME': 'Console', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\\WINDOWS', 'TECHNSFT_LICENSE_FILE': '27000@USLAS0-LIC029', 'TEMP': 'C:\\Users\\eykampC\\AppData\\Local\\Temp', 'TMP': 'C:\\Users\\eykampC\\AppData\\Local\\Temp', 'UATDATA': 'C:\\WINDOWS\\CCM\\UATData\\D9F8C395-CAB8-491d-B8AC-179A1FE1BE77', 'USERDNSDOMAIN': 'JACOBS.COM', 'USERDOMAIN': 'JEG', 'USERDOMAIN_ROAMINGPROFILE': 'JEG', 'USERNAME': 'EykampC', 'USERPROFILE': 'C:\\Users\\eykampC', 'WINDIR': 'C:\\WINDOWS', 'TERM_PROGRAM': 'vscode', 'TERM_PROGRAM_VERSION': '1.47.3', 'LANG': 'en_US.UTF-8', 'COLORTERM': 'truecolor', 'VSCODE_GIT_IPC_HANDLE': '\\\\.\\pipe\\vscode-git-4903b75eaa-sock', 'GIT_ASKPASS': 'c:\\Users\\eykampC\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\extensions\\git\\dist\\askpass.sh', 'VSCODE_GIT_ASKPASS_NODE': 'C:\\Users\\eykampC\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe', 'VSCODE_GIT_ASKPASS_MAIN': 'c:\\Users\\eykampC\\AppData\\Local\\Programs\\Microsoft VS Code\\resources\\app\\extensions\\git\\dist\\askpass-main.js', 'FOR_DISABLE_CONSOLE_CTRL_HANDLER': '1', 'PYTHONIOENCODING': 'UTF-8', 'PYTHONUNBUFFERED': '1'}
             
             

I+00000.562: /handling #1 request "launch" from Adapter/
             Spawned Debuggee[PID=27492].

D+00000.562: /handling #1 request "launch" from Adapter/
             Adapter <-- {
                 "seq": 1,
                 "type": "event",
                 "event": "process",
                 "body": {
                     "startMethod": "launch",
                     "isLocalProcess": true,
                     "systemProcessId": 27492,
                     "name": "c:\\dev\\PIMS - dev\\delme2.py",
                     "pointerSize": 64
                 }
             }

D+00000.562: /handling #1 request "launch" from Adapter/
             Adapter <-- {
                 "seq": 2,
                 "type": "response",
                 "request_seq": 1,
                 "success": true,
                 "command": "launch"
             }

D+00015.718: Adapter --> {
                 "seq": 2,
                 "type": "request",
                 "command": "terminate"
             }

D+00015.734: /handling #2 request "terminate" from Adapter/
             Adapter <-- {
                 "seq": 3,
                 "type": "response",
                 "request_seq": 2,
                 "success": true,
                 "command": "terminate"
             }

I+00015.734: /handling #2 request "terminate" from Adapter/
             Killing Debuggee[PID=27492]

I+00015.765: Debuggee[PID=27492] exited with code 1

D+00015.765: Adapter <-- {
                 "seq": 4,
                 "type": "event",
                 "event": "exited",
                 "body": {
                     "exitCode": 1
                 }
             }

D+00015.765: Adapter <-- {
                 "seq": 5,
                 "type": "event",
                 "event": "terminated"
             }

D+00015.781: Exiting message loop for channel Adapter: No more messages

D+00015.781: Closing Adapter message stream

@eykamp
Copy link
Author

eykamp commented Aug 11, 2020

@int19h
Copy link
Contributor

int19h commented Aug 12, 2020

It's interesting that it didn't produce a server log. What happens if you manually run this in the terminal?

'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\dev\\python.exe' 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.7.96456\\pythonFiles\\lib\\python\\debugpy' '--connect' '127.0.0.1:63737' '--configure-qt' 'auto' '--adapter-access-token' '64123f9f109fb4c0d3243e365fd401c6b6b24c019445608c6c15552c8f25e6a0' 'c:\\dev\\PIMS - dev\\delme2.py'
    

@eykamp
Copy link
Author

eykamp commented Aug 12, 2020

Nothing!

c:\dev>"C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\python.exe" "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy" "--connect" "127.0.0.1:63737" "--configure-qt" "auto" "--adapter-access-token" "64123f9f109fb4c0d3243e365fd401c6b6b24c019445608c6c15552c8f25e6a0" "c:\dev\PIMS - dev\delme2.py"

c:\dev>python "c:\dev\PIMS - dev\delme2.py"
44

c:\dev>

@eykamp
Copy link
Author

eykamp commented Aug 12, 2020

I get a very different reaction with my default version of Python... (the only thing I changed was the python command at the beginning)

c:\dev>python "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy" "--connect" "127.0.0.1:63737" "--configure-qt" "auto" "--adapter-access-token" "64123f9f109fb4c0d3243e365fd401c6b6b24c019445608c6c15552c8f25e6a0" "c:\dev\PIMS - dev\delme2.py"
Could not connect to 127.0.0.1: 63737
Traceback (most recent call last):
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 534, in start_client
    s.connect((host, port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it
Traceback (most recent call last):
  File "C:\Users\eykampC\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\eykampC\AppData\Local\Programs\Python\Python37\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\__main__.py", line 45, in <module>
    cli.main()
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 252, in run_file
    start_debugging(options.target)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\server\cli.py", line 243, in start_debugging
    debugpy.connect(options.address, access_token=options.adapter_access_token)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\common\compat.py", line 204, in kwonly_f
    return f(*args, **kwargs)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\__init__.py", line 135, in connect
    return api.connect(address, access_token=access_token)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\server\api.py", line 141, in debug
    log.reraise_exception("{0}() failed:", func.__name__, level="info")
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\server\api.py", line 139, in debug
    return func(address, settrace_kwargs, **kwargs)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\server\api.py", line 265, in connect
    _settrace(host=host, port=port, client_access_token=access_token, **settrace_kwargs)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy/..\debugpy\server\api.py", line 44, in _settrace
    return pydevd.settrace(*args, **kwargs)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd.py", line 2561, in settrace
    __setup_holder__=__setup_holder__,
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd.py", line 2624, in _locked_settrace
    py_db.connect(host, port)  # Note: connect can raise error.
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\_vendored\pydevd\pydevd.py", line 1222, in connect
    s = start_client(host, port)
  File "c:\Users\eykampC\.vscode\extensions\ms-python.python-2020.7.96456\pythonFiles\lib\python\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_comm.py", line 534, in start_client
    s.connect((host, port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

c:\dev>

@int19h
Copy link
Contributor

int19h commented Aug 12, 2020

The latter one is the expected behavior (it can't find the IDE side, but that's okay).

Does C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\python.exe work for you in general when used manually, e.g. to run a simple hello world type script?

Also, judging by the path, this is actually a conda environment - these usually require activation via conda activate before they can be used. I'm not entirely sure how this applies to ArcGIS, though (i.e. where the conda command is located). But if you can figure it out, try running VSCode itself from a terminal where conda activate succeeded.

@eykamp
Copy link
Author

eykamp commented Aug 13, 2020

Yes:

c:\dev>"C:\Program Files\ArcGIS\Pro\bin\Python\envs\dev\python.exe" -c "print(456)"
456

c:\dev>

What's odd is that this also works from the IDE -- When debugging fails, I can still run the script normally using the green triangle button.

It is a conda environment, and I've never had an issue debugging until the most recent VSCode update, and as I noted running still works. I did try activating the environment from a cmd window, then launch code from there; I experienced the same problem.

@int19h int19h added the bug Something isn't working label Aug 13, 2020
@eykamp
Copy link
Author

eykamp commented Aug 18, 2020

Perhaps helpful... because this problem is really crippling, I've been probing around with lots of print statements trying to figure out where things diverge between the working python (generates stack trace) and non-working python (quits silently).

The issue seems to be a call in api.py, line 128: pydevd.enable_qt_support(qt_mode). In both cases, qt_mode is "auto"; in working python, this returns, and in non-working python, this never comes back.

Forcing qt_mode to be "none" fixes the problem, and I can use the debugger.

@int19h
Copy link
Contributor

int19h commented Aug 18, 2020

This is very interesting, thank you!

This line relates to monkey-patching Qt so that debugger can detect QThread threads. It is configurable in launch.json - "qt": "none" should disable that entirely without the need to muck around with the source.

@eykamp
Copy link
Author

eykamp commented Aug 18, 2020

My lanuch.json doesn't like the "qt" param (it says "property qt is not allowed")

image

@int19h
Copy link
Contributor

int19h commented Aug 18, 2020

Looks like the extension needs to update the schema. The squiggle in the editor shouldn't prevent it from working, though.

@eykamp
Copy link
Author

eykamp commented Aug 18, 2020

Ok, I'll give it a shot. Regardless of whether it works or not, I have a way forward. At this time, I have no need to debug qt threads, so this workaround should not impact me at all.

From my perspective, the immediate case is resolved, but I'll leave it to you to leave it open or close it, depending on whether you think there is something underlying that needs fixing. I'm happy to help if I can.

And, long overdue, thank you for your help. I too sometimes support random people on the internet, and I know it's often thankless work, rewarding when it helps, but quite often results in an awkward surrender that leaves no party satisfied.

Again, thank you.

@int19h
Copy link
Contributor

int19h commented Aug 18, 2020

Thank you for the kind words!

I think the remaining bug here is that either "qt": "auto" is incorrectly detecting Qt where it shouldn't be, or else it's detecting it right (i.e. ArcGIS actually uses it), but patching it goes wrong. I'll update the title accordingly.

@int19h int19h changed the title "Timed out waiting for debuggee to spawn" Debugger times out when "qt":"auto" is used with ArcGIS Python Aug 18, 2020
@int19h
Copy link
Contributor

int19h commented Aug 18, 2020

@fabioz Let's see what the root cause is first, and how expensive fixing it would be. My biggest concern here is that it's not something specific to ArcGIS, but rather merely exposed by it due to the way it configures Qt, or perhaps the version that it uses. If "qt": "auto" can run into issues like this more broadly, we might want to revisit that default.

@eykamp
Copy link
Author

eykamp commented Aug 19, 2020

Just confirming that the "qt": "none" entry works as advertised, despite the warning.

@fabioz
Copy link
Collaborator

fabioz commented Aug 21, 2020

Since it works with a previous version and not this one, this may be the same thing as:

#356

where the environment variables in the launch appear to be different from one launch to the other due to an upgrade (and when it gets to load qt the version is conflicting -- the problem is probably that qt is being loaded too soon as ArcGis probably configures things to work out if the code goes further on).

@fabioz
Copy link
Collaborator

fabioz commented Aug 21, 2020

@eykamp can you run the code below in the current version of the extension as well as in the previous version and let me know if there's any difference in the environment variables from one run to the other?

import sys
print(sys.version)

import os
for key, val in sorted(os.environ.items()):
    print(key)
    for v in val.split(os.pathsep):
        print('    %s' % v)  

print('\nsys.path:')
for v in sys.path:
    print('    %s' % (v,)) 
print('\n')

See: #370 (comment) for how to install a previous version.

@eykamp
Copy link
Author

eykamp commented Aug 21, 2020

I can't easily revert the extension (or the editor), but here is the output of that script, run from within VSCode with the problematic python environment selected: (Note I've removed a couple of corporate entries I do not want to share, but which I am quite sure are irrelevant.)

Run from within VSCode


ADSKFLEX_LICENSE_FILE
    -- deleted --
ADSK_CASCADING_OVERRIDE
    0
AGSDESKTOPJAVA
    C:\Program Files (x86)\ArcGIS\Desktop10.6\
ALLUSERSPROFILE
    C:\ProgramData
APPDATA
    C:\Users\eykampC\AppData\Roaming
COLORTERM
    truecolor
COMMONPROGRAMFILES
    C:\Program Files\Common Files
COMMONPROGRAMFILES(X86)
    C:\Program Files (x86)\Common Files
COMMONPROGRAMW6432
    C:\Program Files\Common Files
COMPUTERNAME
    USPDX1L6T6RXR2
COMSPEC
    C:\WINDOWS\system32\cmd.exe
CONDA_DEFAULT_ENV
    root
CONDA_PREFIX
    C:\Program Files\ArcGIS\Pro\bin\Python
CONDA_PS1_BACKUP
    $P$G
DEFLOGDIR
    C:\ProgramData\McAfee\Endpoint Security\Logs
FLEXLM_TIMEOUT
    2000000
FOR_DISABLE_CONSOLE_CTRL_HANDLER

GIT_ASKPASS
    c:\Users\eykampC\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass.sh
HOMEDRIVE
    C:
HOMEPATH
    \Users\eykampC
LANG
    en_US.UTF-8
LMS
    1.0.171
LM_PROJECT
    T3R2D2PT5
LOCALAPPDATA
    C:\Users\eykampC\AppData\Local
NUMBER_OF_PROCESSORS
    12
ONEDRIVE
    C:\Users\eykampC\OneDrive
ONEDRIVECONSUMER
    C:\Users\eykampC\OneDrive
ORIGINAL_XDG_CURRENT_DESKTOP
    undefined
OS
    Windows_NT
PATH
    C:\Program Files\ArcGIS\Pro\bin
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Library\bin
    C:\Program Files\ArcGIS\Pro\bin
    C:\Program Files\ArcGIS\Pro\bin\Python
    C:\Program Files\ArcGIS\Pro\bin\Python\Library\mingw-w64\bin
    C:\Program Files\ArcGIS\Pro\bin\Python\Library\usr\bin
    C:\Program Files\ArcGIS\Pro\bin\Python\Library\bin
    C:\Program Files\ArcGIS\Pro\bin\Python\Scripts
    C:\ProgramData\Oracle\Java\javapath
    C:\WINDOWS\system32
    C:\WINDOWS
    C:\WINDOWS\System32\Wbem
    C:\WINDOWS\System32\WindowsPowerShell\v1.0\
    C:\Program Files\PuTTY\
    C:\Program Files\Git\cmd
    C:\Utils
    C:\Program Files\nodejs\
    C:\Program Files (x86)\Yarn\bin\
    C:\Program Files\OpenSSL-Win64\bin
    C:\msys64\mingw64\bin_xxx
    C:\Program Files\Intel\WiFi\bin\
    C:\Program Files\Common Files\Intel\WirelessCommon\
    C:\Program Files\Microsoft VS Code\bin
    C:\Users\eykampC\AppData\Local\Programs\Python\Python37\Scripts\
    C:\Users\eykampC\AppData\Local\Programs\Python\Python37\
    C:\Users\eykampC\AppData\Local\Microsoft\WindowsApps
    C:\Users\eykampC\AppData\Local\Programs\Microsoft VS Code\bin
    C:\Users\eykampC\AppData\Local\Pandoc\

    C:\Users\eykampC\AppData\Roaming\npm
    C:\Users\eykampC\AppData\Local\Yarn\bin
    C:\Program Files\Intel\WiFi\bin\
    C:\Program Files\Common Files\Intel\WirelessCommon\
    C:\Users\eykampC\AppData\Local\Programs\Azure Data Studio\bin
PATHEXT
    .COM
    .EXE
    .BAT
    .CMD
    .VBS
    .VBE
    .JS
    .JSE
    .WSF
    .WSH
    .MSC
PROCESSOR_ARCHITECTURE
    AMD64
PROCESSOR_IDENTIFIER
    Intel64 Family 6 Model 158 Stepping 10, GenuineIntel
PROCESSOR_LEVEL
    6
PROCESSOR_REVISION
    9e0a
PROGRAMDATA
    C:\ProgramData
PROGRAMFILES
    C:\Program Files
PROGRAMFILES(X86)
    C:\Program Files (x86)
PROGRAMW6432
    C:\Program Files
PROMPT
    (root) $P$G
PSMODULEPATH
    C:\Program Files\WindowsPowerShell\Modules
    C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
PUBLIC
    C:\Users\Public
PYTHONIOENCODING
    UTF-8
PYTHONUNBUFFERED
    1
SESSIONNAME
    Console
SYSTEMDRIVE
    C:
SYSTEMROOT
    C:\WINDOWS
TECHNSFT_LICENSE_FILE
    27000@FFER4-LIC029
TEMP
    C:\Users\eykampC\AppData\Local\Temp
TERM_PROGRAM
    vscode
TERM_PROGRAM_VERSION
    1.48.0
TMP
    C:\Users\eykampC\AppData\Local\Temp
UATDATA
    C:\WINDOWS\CCM\UATData\D9F8C395-CCB8-491d-B8AC-179A1F11BE77
USERDNSDOMAIN
    JACOBS.COM
USERDOMAIN
    JEG
USERDOMAIN_ROAMINGPROFILE
    JEG
USERNAME
    EykampC
USERPROFILE
    C:\Users\eykampC
VSCODE_GIT_ASKPASS_MAIN
    c:\Users\eykampC\AppData\Local\Programs\Microsoft VS Code\resources\app\extensions\git\dist\askpass-main.js
VSCODE_GIT_ASKPASS_NODE
    C:\Users\eykampC\AppData\Local\Programs\Microsoft VS Code\Code.exe
VSCODE_GIT_IPC_HANDLE
    \\.\pipe\vscode-git-4903b75eaa-sock
WINDIR
    C:\WINDOWS

sys.path:
    c:\dev\PIMS - dev
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python36.zip
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\DLLs
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3
    C:\Users\eykampC\AppData\Roaming\Python\Python36\site-packages
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages
    C:\Program Files\ArcGIS\Pro\bin
    C:\Program Files\ArcGIS\Pro\Resources\ArcPy
    C:\Program Files\ArcGIS\Pro\Resources\ArcToolbox\Scripts
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\future-0.18.2-py3.6.egg
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\pytz-2019.3-py3.6.egg
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\win32
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\win32\lib
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\Pythonwin
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\pywin32_ctypes-0.2.0-py3.6.egg
    C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\sympy-1.5.1-py3.6.egg

@int19h
Copy link
Contributor

int19h commented Aug 25, 2020

One of the differences between b11 and b12 was that we started to enable Qt support by default - it used to be effectively "none", now it's "auto". And the way pydevd handles "auto" is by probing a bunch of different imports one by one, if I remember correctly? So perhaps in this case that causes an incorrect version to load?

@eykamp
Copy link
Author

eykamp commented Aug 25, 2020

Would it make sense to break out this probing code into a separate script that I could run locally and see where it fails? I'm presuming there's something in my environment that it is objecting to and knowing what that is might be useful.

@int19h
Copy link
Contributor

int19h commented Aug 25, 2020

Here's what it does:

if qt_support_mode == 'auto':
patch_qt_on_import = None
try:
import PySide2 # @UnresolvedImport @UnusedImport
qt_support_mode = 'pyside2'
except:
try:
import Pyside # @UnresolvedImport @UnusedImport
qt_support_mode = 'pyside'
except:
try:
import PyQt5 # @UnresolvedImport @UnusedImport
qt_support_mode = 'pyqt5'
except:
try:
import PyQt4 # @UnresolvedImport @UnusedImport
qt_support_mode = 'pyqt4'
except:
return

To compare with ArcGIS default environment, it would be interesting to see what sys.modules looks like on the latter (presumably it would have the correct version of PyQt or PySide loaded).

@eykamp
Copy link
Author

eykamp commented Aug 25, 2020

In my case, qt_support_mode == 'pyqt5'

patch_qt_on_import = None
try:
    import PySide2  # @UnresolvedImport @UnusedImport
    qt_support_mode = 'pyside2'
except:
    try:
        import Pyside  # @UnresolvedImport @UnusedImport
        qt_support_mode = 'pyside'
    except:
        try:
            import PyQt5  # @UnresolvedImport @UnusedImport
            qt_support_mode = 'pyqt5'
        except:
            try:
                import PyQt4  # @UnresolvedImport @UnusedImport
                qt_support_mode = 'pyqt4'
            except:
                print("here")

import sys
print(qt_support_mode)
print(sys.modules)

prints:

pyqt5
{'builtins': <module 'builtins' (built-in)>, 'sys': <module 'sys' (built-in)>, '_frozen_importlib': <module 'importlib._bootstrap' (frozen)>, '_imp': <module '_imp' (built-in)>, '_warnings':
<module '_warnings' (built-in)>, '_thread': <module '_thread' (built-in)>, '_weakref': <module '_weakref' (built-in)>, '_frozen_importlib_external': <module 'importlib._bootstrap_external' (frozen)>, '_io': <module 'io' (built-in)>, 'marshal': <module 'marshal' (built-in)>, 'nt': <module 'nt' (built-in)>, 'winreg': <module 'winreg' (built-in)>, 'zipimport': <module 'zipimport' (built-in)>, 'encodings': <module 'encodings' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\__init__.py'>, 'codecs': <module 'codecs' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\codecs.py'>, '_codecs': <module '_codecs' (built-in)>, 'encodings.aliases': <module 'encodings.aliases' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\aliases.py'>, 'encodings.utf_8': <module 'encodings.utf_8' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\utf_8.py'>, '_signal': <module '_signal' (built-in)>, 'encodings.latin_1': <module 'encodings.latin_1' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\latin_1.py'>, 'io': <module 'io' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\io.py'>, 'abc': <module 'abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\abc.py'>, '_weakrefset': <module '_weakrefset' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_weakrefset.py'>, 'site': <module 'site' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site.py'>, 'os': <module 'os' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\os.py'>, 'errno': <module 'errno' (built-in)>, 'stat': <module 'stat' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\stat.py'>, '_stat': <module '_stat' (built-in)>, 'ntpath': <module 'ntpath' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\ntpath.py'>, 'genericpath': <module 'genericpath' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\genericpath.py'>, 'os.path': <module 'ntpath' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\ntpath.py'>,
'_collections_abc': <module '_collections_abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_collections_abc.py'>, '_sitebuiltins': <module '_sitebuiltins' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_sitebuiltins.py'>, 'sysconfig': <module 'sysconfig' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\sysconfig.py'>, '_bootlocale': <module '_bootlocale' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_bootlocale.py'>, '_locale': <module '_locale' (built-in)>, 'encodings.cp1252': <module 'encodings.cp1252' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\cp1252.py'>, 'types': <module 'types' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\types.py'>, 'functools': <module 'functools' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\functools.py'>, '_functools': <module '_functools' (built-in)>, 'collections': <module 'collections' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\collections\\__init__.py'>, 'operator': <module 'operator' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\operator.py'>, '_operator': <module '_operator' (built-in)>, 'keyword': <module 'keyword' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\keyword.py'>, 'heapq': <module 'heapq' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\heapq.py'>, '_heapq': <module '_heapq' (built-in)>, 'itertools': <module 'itertools' (built-in)>, 'reprlib': <module 'reprlib' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\reprlib.py'>, '_collections': <module '_collections' (built-in)>, 'weakref': <module 'weakref' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\weakref.py'>, 'collections.abc': <module 'collections.abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\collections\\abc.py'>, 'importlib': <module 'importlib' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\__init__.py'>, 'importlib._bootstrap': <module 'importlib._bootstrap' (frozen)>, 'importlib._bootstrap_external': <module 'importlib._bootstrap_external' (frozen)>, 'warnings': <module 'warnings' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\warnings.py'>, 'importlib.util': <module 'importlib.util' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\util.py'>, 'importlib.abc': <module 'importlib.abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\abc.py'>, 'importlib.machinery': <module 'importlib.machinery' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\machinery.py'>, 'contextlib': <module 'contextlib' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\contextlib.py'>, 'mpl_toolkits': <module 'mpl_toolkits' (namespace)>, 'encodings.cp437': <module 'encodings.cp437' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\cp437.py'>, 'runpy': <module 'runpy' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\runpy.py'>, 'pkgutil': <module 'pkgutil' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\pkgutil.py'>, '__main__': <module '__main__' from 'c:\\dev\\PIMS - dev\\test_pyright.py'>, '__future__': <module '__future__' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\__future__.py'>, 'debugpy': <module 'debugpy' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\__init__.py'>, 'debugpy._version': <module 'debugpy._version' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\_version.py'>, 'json': <module 'json' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\json\\__init__.py'>, 'json.decoder': <module 'json.decoder' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\json\\decoder.py'>, 're': <module 're' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\re.py'>, 'enum': <module 'enum' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\enum.py'>, 'sre_compile': <module 'sre_compile' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\sre_compile.py'>, '_sre': <module '_sre' (built-in)>, 'sre_parse': <module 'sre_parse' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\sre_parse.py'>, 'sre_constants': <module 'sre_constants' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\sre_constants.py'>,
'copyreg': <module 'copyreg' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\copyreg.py'>, 'json.scanner': <module 'json.scanner' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\json\\scanner.py'>, '_json': <module '_json' (built-in)>, 'json.encoder': <module 'json.encoder' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\json\\encoder.py'>, 'debugpy.common': <module 'debugpy.common' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\common\\__init__.py'>, 'debugpy.common.compat': <module 'debugpy.common.compat' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\common\\compat.py'>, 'inspect': <module 'inspect' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\inspect.py'>, 'ast': <module 'ast' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\ast.py'>, '_ast': <module '_ast' (built-in)>, 'dis': <module 'dis' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\dis.py'>, 'opcode': <module 'opcode' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\opcode.py'>, '_opcode': <module '_opcode' (built-in)>, 'linecache': <module 'linecache' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\linecache.py'>, 'tokenize': <module 'tokenize' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\tokenize.py'>, 'token': <module 'token' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\token.py'>, 'debugpy.common.fmt': <module 'debugpy.common.fmt' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\common\\fmt.py'>, 'string': <module 'string' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\string.py'>, '_string': <module '_string' (built-in)>, 'debugpy.common.json': <module 'debugpy.common.json' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\common\\json.py'>, 'queue': <module 'queue' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\queue.py'>, 'threading': <module 'threading' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\threading.py'>, 'time': <module 'time' (built-in)>, 'traceback': <module 'traceback' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\traceback.py'>,
'debugpy.server': <module 'debugpy.server' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\server\\__init__.py'>, 'debugpy._vendored': <module 'debugpy._vendored' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\_vendored\\__init__.py'>, 'debugpy._vendored._util': <module 'debugpy._vendored._util' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\_vendored\\_util.py'>, 'debugpy._vendored.force_pydevd': <module 'debugpy._vendored.force_pydevd' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy/..\\debugpy\\_vendored\\force_pydevd.py'>, '_pydevd_bundle': <module '_pydevd_bundle' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\__init__.py'>, '_pydevd_bundle.pydevd_constants': <module '_pydevd_bundle.pydevd_constants' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\pydevd_constants.py'>, 'platform': <module 'platform' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\platform.py'>, 'subprocess': <module 'subprocess' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\subprocess.py'>, 'signal': <module 'signal' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\signal.py'>, 'msvcrt': <module 'msvcrt' (built-in)>, '_winapi': <module '_winapi' (built-in)>, 'struct': <module 'struct' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\struct.py'>, '_struct': <module '_struct' (built-in)>, 'encodings.ascii': <module 'encodings.ascii' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\ascii.py'>, 'encodings.idna': <module 'encodings.idna' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\idna.py'>, 'stringprep': <module 'stringprep' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\stringprep.py'>, 'unicodedata': <module 'unicodedata' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\DLLs\\unicodedata.pyd'>, '_pydevd_bundle.pydevd_vm_type':
<module '_pydevd_bundle.pydevd_vm_type' from 'c:\\Users\\eykampC\\.vscode\\extensions\\ms-python.python-2020.8.103604\\pythonFiles\\lib\\python\\debugpy\\_vendored\\pydevd\\_pydevd_bundle\\pydevd_vm_type.py'>, '_pydev_imps': <module '_pydev_imps' from 'c:\\Users\\

@int19h
Copy link
Contributor

int19h commented Aug 25, 2020

This is strange - if it's set to "pyqt5", it means that it had successfully imported PyQt5, so that ought to be in sys.modules.

What does PyQt5.__file__ say?

@int19h
Copy link
Contributor

int19h commented Aug 25, 2020

Also, for a slightly more readable output for the module list:

for name in sorted(sys.modules): print(name, "\n\t", sys.modules[name])

@eykamp
Copy link
Author

eykamp commented Aug 25, 2020

The above was run from within VSCode using the debug function. When I run from python directly in the environment, I get this (showing the presence of pyqt5)

I admit I don't fully understand which environments VSCode uses and when; sometimes I have warnings that modules don't exist, but the code runs fine, proving that they do.

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>python "c:\dev\PIMS - dev\test_pyright.py"
pyqt5
PyQt5
         <module 'PyQt5' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site-packages\\PyQt5\\__init__.py'>
__main__
         <module '__main__' from 'c:\\dev\\PIMS - dev\\test_pyright.py'>
_bootlocale
         <module '_bootlocale' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_bootlocale.py'>
_codecs
         <module '_codecs' (built-in)>
_collections
         <module '_collections' (built-in)>
_collections_abc
         <module '_collections_abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_collections_abc.py'>
_frozen_importlib
         <module 'importlib._bootstrap' (frozen)>
_frozen_importlib_external
         <module 'importlib._bootstrap_external' (frozen)>
_functools
         <module '_functools' (built-in)>
_heapq
         <module '_heapq' (built-in)>
_imp
         <module '_imp' (built-in)>
_io
         <module 'io' (built-in)>
_locale
         <module '_locale' (built-in)>
_operator
         <module '_operator' (built-in)>
_signal
         <module '_signal' (built-in)>
_sitebuiltins
         <module '_sitebuiltins' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_sitebuiltins.py'>
_stat
         <module '_stat' (built-in)>
_thread
         <module '_thread' (built-in)>
_warnings
         <module '_warnings' (built-in)>
_weakref
         <module '_weakref' (built-in)>
_weakrefset
         <module '_weakrefset' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\_weakrefset.py'>
abc
         <module 'abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\abc.py'>
builtins
         <module 'builtins' (built-in)>
codecs
         <module 'codecs' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\codecs.py'>
collections
         <module 'collections' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\collections\\__init__.py'>
collections.abc
         <module 'collections.abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\collections\\abc.py'>
contextlib
         <module 'contextlib' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\contextlib.py'>
encodings
         <module 'encodings' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\__init__.py'>
encodings.aliases
         <module 'encodings.aliases' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\aliases.py'>
encodings.cp1252
         <module 'encodings.cp1252' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\cp1252.py'>
encodings.cp437
         <module 'encodings.cp437' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\cp437.py'>
encodings.latin_1
         <module 'encodings.latin_1' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\latin_1.py'>
encodings.utf_8
         <module 'encodings.utf_8' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\encodings\\utf_8.py'>
errno
         <module 'errno' (built-in)>
functools
         <module 'functools' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\functools.py'>
genericpath
         <module 'genericpath' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\genericpath.py'>
heapq
         <module 'heapq' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\heapq.py'>
importlib
         <module 'importlib' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\__init__.py'>
importlib._bootstrap
         <module 'importlib._bootstrap' (frozen)>
importlib._bootstrap_external
         <module 'importlib._bootstrap_external' (frozen)>
importlib.abc
         <module 'importlib.abc' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\abc.py'>
importlib.machinery
         <module 'importlib.machinery' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\machinery.py'>
importlib.util
         <module 'importlib.util' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\importlib\\util.py'>
io
         <module 'io' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\io.py'>
itertools
         <module 'itertools' (built-in)>
keyword
         <module 'keyword' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\keyword.py'>
marshal
         <module 'marshal' (built-in)>
mpl_toolkits
         <module 'mpl_toolkits' (namespace)>
nt
         <module 'nt' (built-in)>
ntpath
         <module 'ntpath' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\ntpath.py'>
operator
         <module 'operator' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\operator.py'>
os
         <module 'os' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\os.py'>
os.path
         <module 'ntpath' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\ntpath.py'>
reprlib
         <module 'reprlib' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\reprlib.py'>
site
         <module 'site' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\site.py'>
stat
         <module 'stat' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\stat.py'>
sys
         <module 'sys' (built-in)>
sysconfig
         <module 'sysconfig' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\sysconfig.py'>
types
         <module 'types' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\types.py'>
warnings
         <module 'warnings' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\warnings.py'>
weakref
         <module 'weakref' from 'C:\\Program Files\\ArcGIS\\Pro\\bin\\Python\\envs\\arcgispro-py3\\lib\\weakref.py'>
winreg
         <module 'winreg' (built-in)>
zipimport
         <module 'zipimport' (built-in)>

(arcgispro-py3) C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3>

@eykamp
Copy link
Author

eykamp commented Aug 25, 2020

PyQt5.__file__ == "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\PyQt5\__init__.py"

(run from inside VSCode)

@fabioz
Copy link
Collaborator

fabioz commented Oct 22, 2020

I was thinking that it should be possible to have native thread detection when running in the frame eval mode.

In this case, on frame eval mode (so, only Python 3.6 onwards with compiled extensions available), we actually have a hook that doesn't require the tracing -- and where we could enable tracing for untraced threads (in which case the qt patching wouldn't be needed in the first place).

I'll investigate to see if this is actually feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants