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

Cannot debug Python app (ptvsd error: unrecognized switch --default) #1743

Closed
anthonychu opened this issue Dec 9, 2019 · 2 comments
Closed

Comments

@anthonychu
Copy link
Member

anthonychu commented Dec 9, 2019

Environment

Version: 1.40.2
Commit: f359dd69833dd8800b54d458f6d37ab7c78df520
Date: 2019-11-25T14:52:45.129Z
Electron: 6.1.5
Chrome: 76.0.3809.146
Node.js: 12.4.0
V8: 7.6.303.31-electron.0
OS: Darwin x64 18.7.0

Extension version 0.20.1
Python 3.7.5

Repro

  1. Use VS Code to create functions project in an empty folder
  2. Add an HTTP triggered function
  3. Start debugging (F5)
  4. Python worker fails to start (Error: unrecognized switch --default).

Logs

> Executing task: .venv/bin/python -m pip install -r requirements.txt <

source /Users/antchu/source/temp/test-python-debug-error/.venv/bin/activate
Requirement already satisfied: azure-functions in ./.venv/lib/python3.7/site-packages (from -r requirements.txt (line 1)) (1.0.5)
WARNING: You are using pip version 19.2.3, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Terminal will be reused by tasks, press any key to close it.

> Executing task: . .venv/bin/activate && func host start <

Found Python version 3.7.5 (python).

                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (2.7.1948 Commit hash: 29a0626ded3ae99c4111f66763f27bb9fb564103)
Function Runtime Version: 2.0.12888.0
[12/9/19 12:58:27 AM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: 'f9ece8a2-a13b-49e0-b193-685fa53a1b5e'
[12/9/19 12:58:27 AM] Reading host configuration file '/Users/antchu/source/temp/test-python-debug-error/host.json'
[12/9/19 12:58:27 AM] Host configuration file read:
[12/9/19 12:58:27 AM] {
[12/9/19 12:58:27 AM]   "version": "2.0"
[12/9/19 12:58:27 AM] }
[12/9/19 12:58:27 AM] Reading functions metadata
[12/9/19 12:58:27 AM] 1 functions found
[12/9/19 12:58:28 AM] Initializing Warmup Extension.
[12/9/19 12:58:29 AM] Initializing Host. OperationId: 'f9ece8a2-a13b-49e0-b193-685fa53a1b5e'.
[12/9/19 12:58:29 AM] Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=f9ece8a2-a13b-49e0-b193-685fa53a1b5e
[12/9/19 12:58:29 AM] LoggerFilterOptions
[12/9/19 12:58:29 AM] {
[12/9/19 12:58:29 AM]   "MinLevel": "None",
[12/9/19 12:58:29 AM]   "Rules": [
[12/9/19 12:58:29 AM]     {
[12/9/19 12:58:29 AM]       "ProviderName": null,
[12/9/19 12:58:29 AM]       "CategoryName": null,
[12/9/19 12:58:29 AM]       "LogLevel": null,
[12/9/19 12:58:29 AM]       "Filter": "<AddFilter>b__0"
[12/9/19 12:58:29 AM]     },
[12/9/19 12:58:29 AM]     {
[12/9/19 12:58:29 AM]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[12/9/19 12:58:29 AM]       "CategoryName": null,
[12/9/19 12:58:29 AM]       "LogLevel": "None",
[12/9/19 12:58:29 AM]       "Filter": null
[12/9/19 12:58:29 AM]     },
[12/9/19 12:58:29 AM]     {
[12/9/19 12:58:29 AM]       "ProviderName": "Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[12/9/19 12:58:29 AM]       "CategoryName": null,
[12/9/19 12:58:29 AM]       "LogLevel": null,
[12/9/19 12:58:29 AM]       "Filter": "<AddFilter>b__0"
[12/9/19 12:58:29 AM]     }
[12/9/19 12:58:29 AM]   ]
[12/9/19 12:58:29 AM] }
[12/9/19 12:58:29 AM] FunctionResultAggregatorOptions
[12/9/19 12:58:29 AM] {
[12/9/19 12:58:29 AM]   "BatchSize": 1000,
[12/9/19 12:58:29 AM]   "FlushTimeout": "00:00:30",
[12/9/19 12:58:29 AM]   "IsEnabled": true
[12/9/19 12:58:29 AM] }
[12/9/19 12:58:29 AM] SingletonOptions
[12/9/19 12:58:29 AM] {
[12/9/19 12:58:29 AM]   "LockPeriod": "00:00:15",
[12/9/19 12:58:29 AM]   "ListenerLockPeriod": "00:00:15",
[12/9/19 12:58:29 AM]   "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[12/9/19 12:58:29 AM]   "LockAcquisitionPollingInterval": "00:00:05",
[12/9/19 12:58:29 AM]   "ListenerLockRecoveryPollingInterval": "00:01:00"
[12/9/19 12:58:29 AM] }
[12/9/19 12:58:29 AM] HttpOptions
[12/9/19 12:58:29 AM] {
[12/9/19 12:58:29 AM]   "DynamicThrottlesEnabled": false,
[12/9/19 12:58:29 AM]   "MaxConcurrentRequests": -1,
[12/9/19 12:58:29 AM]   "MaxOutstandingRequests": -1,
[12/9/19 12:58:29 AM]   "RoutePrefix": "api"
[12/9/19 12:58:29 AM] }
[12/9/19 12:58:29 AM] Starting JobHost
[12/9/19 12:58:29 AM] Starting Host (HostId=antchumacbook-1915481034, InstanceId=dd47a238-31fb-4367-8a9d-a688c9f76565, Version=2.0.12888.0, ProcessId=97739, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=(null))
[12/9/19 12:58:29 AM] Loading functions metadata
[12/9/19 12:58:29 AM] 1 functions loaded
[12/9/19 12:58:29 AM] Loading proxies metadata
[12/9/19 12:58:29 AM] Initializing Azure Function proxies
[12/9/19 12:58:29 AM] 0 proxies loaded
[12/9/19 12:58:30 AM] Starting worker process:python  /Users/antchu/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd --default --host 127.0.0.1 --port 9091 --wait "/usr/local/Cellar/azure-functions-core-tools/2.7.1948/workers/python/3.7/OSX/X64/worker.py" --host 127.0.0.1 --port 60020 --workerId 949052c0-b4b1-424b-b3f3-e0a6963c3eb1 --requestId a90bb65a-c493-42be-afa2-302b02e8e048 --grpcMaxMessageLength 134217728
[12/9/19 12:58:30 AM] python process with Id=97790 started
[12/9/19 12:58:30 AM] Generating 1 job function(s)
[12/9/19 12:58:30 AM] Found the following functions:
[12/9/19 12:58:30 AM] Host.Functions.HttpTrigger
[12/9/19 12:58:30 AM] 
[12/9/19 12:58:30 AM] Initializing function HTTP routes
[12/9/19 12:58:30 AM] Mapped function route 'api/HttpTrigger' [get,post] to 'HttpTrigger'
[12/9/19 12:58:30 AM] 
[12/9/19 12:58:30 AM] Host initialized (1392ms)
[12/9/19 12:58:30 AM] Host started (1411ms)
[12/9/19 12:58:30 AM] Job host started
[12/9/19 12:58:30 AM] ptvsd 5.0.0a7
[12/9/19 12:58:30 AM] See https://aka.ms/ptvsd for documentation.
[12/9/19 12:58:30 AM] Usage: ptvsd [--client] --host <address> [--port <port>]
[12/9/19 12:58:30 AM]              [--wait]
[12/9/19 12:58:30 AM]              [--no-subprocesses]
[12/9/19 12:58:30 AM]              [--log-dir <path>] [--log-stderr]
[12/9/19 12:58:30 AM]              <filename> | -m <module> | -c <code> | --pid <pid>
[12/9/19 12:58:30 AM] Error: unrecognized switch --default
[12/9/19 12:58:30 AM] Starting worker process:python  /Users/antchu/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd --default --host 127.0.0.1 --port 9091 --wait "/usr/local/Cellar/azure-functions-core-tools/2.7.1948/workers/python/3.7/OSX/X64/worker.py" --host 127.0.0.1 --port 60020 --workerId 0daba436-6cbe-47bf-adb4-77e3c092e28c --requestId e435a107-f0db-4a6b-8a3d-11b3e504e21b --grpcMaxMessageLength 134217728
[12/9/19 12:58:30 AM] python process with Id=97796 started
Hosting environment: Production
Content root path: /Users/antchu/source/temp/test-python-debug-error
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.

Http Functions:

        HttpTrigger: [GET,POST] http://localhost:7071/api/HttpTrigger

[12/9/19 12:58:31 AM] ptvsd 5.0.0a7
[12/9/19 12:58:31 AM] See https://aka.ms/ptvsd for documentation.
[12/9/19 12:58:31 AM] Usage: ptvsd [--client] --host <address> [--port <port>]
[12/9/19 12:58:31 AM]              [--wait]
[12/9/19 12:58:31 AM]              [--no-subprocesses]
[12/9/19 12:58:31 AM]              [--log-dir <path>] [--log-stderr]
[12/9/19 12:58:31 AM]              <filename> | -m <module> | -c <code> | --pid <pid>
[12/9/19 12:58:31 AM] Error: unrecognized switch --default
[12/9/19 12:58:31 AM] Starting worker process:python  /Users/antchu/.vscode/extensions/ms-python.python-2019.11.50794/pythonFiles/lib/python/new_ptvsd/no_wheels/ptvsd --default --host 127.0.0.1 --port 9091 --wait "/usr/local/Cellar/azure-functions-core-tools/2.7.1948/workers/python/3.7/OSX/X64/worker.py" --host 127.0.0.1 --port 60020 --workerId 22936055-da99-4980-8703-2756da6c9fe9 --requestId f8c69823-cf3e-4fc9-a58d-7756ffd3042b --grpcMaxMessageLength 134217728
[12/9/19 12:58:31 AM] python process with Id=97800 started
[12/9/19 12:58:31 AM] ptvsd 5.0.0a7
[12/9/19 12:58:31 AM] See https://aka.ms/ptvsd for documentation.
[12/9/19 12:58:31 AM] Usage: ptvsd [--client] --host <address> [--port <port>]
[12/9/19 12:58:31 AM]              [--wait]
[12/9/19 12:58:31 AM]              [--no-subprocesses]
[12/9/19 12:58:31 AM]              [--log-dir <path>] [--log-stderr]
[12/9/19 12:58:31 AM]              <filename> | -m <module> | -c <code> | --pid <pid>
[12/9/19 12:58:31 AM] Error: unrecognized switch --default
[12/9/19 12:58:31 AM] Exceeded language worker restart retry count for runtime:python. Shutting down Functions Host
[12/9/19 12:58:31 AM] Stopping host...
[12/9/19 12:58:31 AM] Stopping JobHost
[12/9/19 12:58:31 AM] Job host stopped
[12/9/19 12:58:31 AM] Host shutdown completed.
Application is shutting down...

Terminal will be reused by tasks, press any key to close it.

launch.json

{
    "configurations": [
        {
            "name": "Attach to Python Functions",
            "type": "python",
            "request": "attach",
            "port": 9091,
            "preLaunchTask": "func: host start"
        }
    ]
}

tasks.json

{
    "tasks": [
        {
            "type": "func",
            "command": "host start",
            "problemMatcher": "$func-watch",
            "isBackground": true,
            "dependsOn": "pipInstall"
        },
        {
            "label": "pipInstall",
            "type": "shell",
            "osx": {
                "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
            },
            "windows": {
                "command": "${config:azureFunctions.pythonVenv}\\Scripts\\python -m pip install -r requirements.txt"
            },
            "linux": {
                "command": "${config:azureFunctions.pythonVenv}/bin/python -m pip install -r requirements.txt"
            },
            "problemMatcher": []
        }
    ]
}
@ejizba
Copy link
Contributor

ejizba commented Dec 9, 2019

This is a known issue in the Python extension: microsoft/vscode-python#8685. Users can wait for them to release the fix or try downgrading to an older version of the Python extension with the command palette
Screen Shot 2019-12-04 at 3 36 25 PM

This is the version I'm on where it works:
Screen Shot 2019-12-04 at 3 36 38 PM

@ejizba
Copy link
Contributor

ejizba commented Apr 8, 2020

This was fixed in the python extension

@ejizba ejizba closed this as completed Apr 8, 2020
@vscodebot vscodebot bot locked and limited conversation to collaborators May 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants