How to enable debugging in Visual Studio Code on Windows

254 views
Skip to first unread message

Andrew Rogers

unread,
Jul 30, 2021, 5:36:35 AM7/30/21
to py4web
Sorry for the dumb question...

I can debug other python apps fine. I have py4web launching from VS Code using the launch.json file described below. But my break points in the examples apps (in models.py and controllers.py)  are ignored. What am I missing?

My launch.json file looks like this:
    "configurations": [
        {
            "name": "py4web",
            "type": "python",
            "request": "launch",
            "python": "c:/Python39/python.exe",
            "program": "D:/Andrew/github/py4web/py4web.py",
            "args": ["run","D:/Andrew/github/py4web/apps"],
            "cwd": "${workspaceRoot}",            
            "console": "integratedTerminal",
            "justMyCode": true          
        }
    ]

Nico Zanferrari

unread,
Jul 30, 2021, 3:54:23 PM7/30/21
to Andrew Rogers, py4web
Hi Andrew,

it works fine for me on Ubuntu. I've just tried and it's similar on Windows (installed locally from source), here is my launch.json file:

    "configurations": [
        {
            "name""Python: Current File",
            "type""python",
            "request""launch",
            "program""c:/users/nico/desktop/py4web/py4web.py",
            "console""integratedTerminal",
            "args": ["run""apps"]
        }
    ]


where I've just changed the program value and added the args one.

The resulting execution command is:

  & 'C:\Users\nico\AppData\Local\Programs\Python\Python38\python.exe' 'c:\Users\nico\.vscode\extensions\ms-python.python-2021.7.1060902895\pythonFiles\lib\python\debugpy\launcher' '50263' '--' 'c:/users/nico/desktop/py4web/py4web.py' 'run' 'apps'

Do you see your breakpoints on the lower left portion of the debug panel?

image.png

Can you also try to place one breakpoint on line 31 of apps/_dashboard/__init__.py ? It should be automatically risen at py4web startup.


Nico



--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/2525c7bd-0218-435d-b9d6-d497644aba51n%40googlegroups.com.

Andrew Rogers

unread,
Aug 2, 2021, 12:39:56 AM8/2/21
to py4web
Many thanks Nico. I think my problem was that I had the wrong folder open in VS Code. I had opened the 'apps' folder in VSC not the py4web folder.  I should have realised that that would be a problem because I got the 'apps' does not exist error when configured using "args": ["run","apps"]

Is this something that I could add to the documentation? I read through that (maybe not carefully enough) but perhaps it needs to be spelled out a little more explicitly for people like me.

Jorge Salvat

unread,
Aug 2, 2021, 5:45:16 PM8/2/21
to py4web
Hi,

I usually open the folder of the app I'm working on VSCode, but then my launch.json is:

"version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Py4Web",
            "type": "python",
            "request": "launch",
            "program": "py4web.py",
            "cwd": "c:/wwwroot/py4web-master/",
            "args": [
                "run",
                "apps"
            ],
            "console": "integratedTerminal"
        }
    ]

Hope this helps!
Reply all
Reply to author
Forward
0 new messages