Debugging Django in VSCode fails on imp.py

Viewed 531

I am unable to debug my Django app. I am using virtualenv and have configured my VSCode workspace to point to the absolute path within my virtual environment for python.

"python.pythonPath": "/Users/Me/PyProjs/proj_env/bin/python"

When trying to debug, however, the editor jumps to the imp.py file (which is located at ~/proj_env/lib/python3.4) and fails at the new_module() method.

def new_module(name):
    """**DEPRECATED**

    Create a new module.

    The module is not entered into sys.modules.

    """
    return types.ModuleType(name) #Editor breaks here.

Inspecting the name variable, I see it is set to "__main__". When stepping through, the editor exits debug mode and no errors or exceptions are logged in the Debug Console.

Anybody know what my issue could possibly be? I just want to debug my application!

2 Answers

You probably have stopOnEntry set to true in your launch.json. Try setting it to false:

{
        "name": "Python: Django",
        "type": "python",
        "request": "launch",
        "stopOnEntry": false,
        "pythonPath": "${config:python.pythonPath}",
        "program": "${workspaceFolder}/manage.py",
        "cwd": "${workspaceFolder}",
        "args": [
            "runserver",
            "--noreload",
            "--nothreading"
        ],
        "env": {},
        "envFile": "${workspaceFolder}/.env",
        "debugOptions": [
            "RedirectOutput",
            "DjangoDebugging"
        ]
    },
Related