AtlasUser5
AtlasUser5

Reputation: 81

Django debugger does not start by VS Code launch.json

Until recently my Django projects would debug fine using launch.json file. But it stopped working today and I have no idea about it.

Changes made by me in system were:

  1. Clean-Installing Windows
  2. Installing python in default path just for current user and not all users

Problem Description:

  1. As soon as I click F5 key the debugger starts for some milliseconds and stops automatically without any prompt. As it does not shows any error I tried to log errors by nothing in it. It does not even load terminal to run commands.

The added configuration in launch.json file is as below:

{
    "configurations": [
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}\\manage.py",
            "args": [
                "runserver"
            ],
            "django": true,
            "justMyCode": true,
            "logToFile": true,
            "console": "integratedTerminal",
            "cwd": "${workspaceFolder}",
            "host": "localhost"
        }
    ]
}

Can someone help to troubleshoot this, I have already tried:

  1. Creating new projects
  2. Reinstalling Python
  3. Creating new environment
  4. Resetting VS Code Sync Settings
  5. Run other dubug configurations {they are working fine)
  6. Changing django debug configuration

My current options are:

  1. Research more (Already spent a hours would take more)
  2. Wait for solution by someone
  3. Clean Install Windows and all software's (Would be like BhramaAstra)

Upvotes: 4

Views: 2742

Answers (2)

Paras Patel
Paras Patel

Reputation: 9

  • When we install the VS code, the debugger configurations are set by default

  • let me give you the default configurations.

    { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Python Debugger: Django", "type": "debugpy", "request": "launch", "program": "${workspaceFolder}/manage.py", "args": [ "runserver" ], "django": true } ] }

Please find this code and try to replace this code with old code in .vscode/launch.json File.

Thanks.

Launch.json file

Upvotes: -1

AtlasUser5
AtlasUser5

Reputation: 81

Posting answer within few minutes of posting question seems weird but I got a solution that could help to get perfect answer to my problem.

The problem was the python environment path: I created environment in documents folder of C drive of current non-admin user hoping of no issues since python is installed for just the current user in default path. But as soon as created new environment in current user directory the debugger started working normally.

The issue is related to permissions and file paths, hope this helps to get solution to new questions generated:

  1. Why can't I use Documents folder for creating a python environment?
  2. Is there some other solution to my actual problem?

Adding images for further details:

  1. Debugger not working from this environment - enter image description here
  2. Debugger working as usual if environment created here - enter image description here

Upvotes: 3

Related Questions