Python Forum
Launch.json isn't working - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Launch.json isn't working (/thread-2438.html)



Launch.json isn't working - RemyLeBleau - Mar-16-2017

Hey guys,

I am pretty new to coding and am using a MacBook Pro and have downloaded Visual Studio Code.  The problem is when I go to debug what I have written the launch.json file was throwing alot of bugs. So I tried editing the file and could not seem to fix it(although I think I came close) problem being I have now erased the entirety of launch.json on accident so I need to get the correct code put back into that file.


RE: Launch.json isn't working - Larz60+ - Mar-16-2017

what is launch.json???
how about showing the code?


RE: Launch.json isn't working - RemyLeBleau - Mar-16-2017

I cannot figure out how to post pictures or else I would show the code.
I believe the launch.json file should be the debugger?


RE: Launch.json isn't working - Larz60+ - Mar-16-2017

You don't need to post images, it's not the way to go.

to post code, do the following:
  • Copy code from source with ctrl-c
  • Paste to post with ctrl-shift-v
  • Highlight the code
  • Click python icon in thread toolbar.



RE: Launch.json isn't working - RemyLeBleau - Mar-16-2017

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "PySpark",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "osx": {
                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
            },
            "windows": {
                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit.cmd"
            },
            "linux": {
                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"
            },
            "program": "${file}",
            "cwd": "${workspaceRoot}",
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Python Module",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "module": "module.name",
            "cwd": "${workspaceRoot}",
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Integrated Terminal/Console",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${file}",
            "cwd": null,
            "console": "integratedTerminal",
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit"
            ]
        },
        {
            "name": "External Terminal/Console",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${file}",
            "cwd": null,
            "console": "externalTerminal",
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit"
            ]
        },
        {
            "name": "Django",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${workspaceRoot}/manage.py",
            "cwd": "${workspaceRoot}",
            "args": [
                "runserver",
                "--noreload"
            ],
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput",
                "DjangoDebugging"
            ]
        },
        {
            "name": "Flask",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "pythonPath": "${config.python.pythonPath}",
            "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",
            "cwd": "${workspaceRoot}",
            "env": {
                "FLASK_APP": "${workspaceRoot}/quickstart/app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ],
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Flask (old)",
            "type": "python",
            "request": "launch",
            "stopOnEntry": false,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${workspaceRoot}/run.py",
            "cwd": "${workspaceRoot}",
            "args": [],
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Pyramid",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "cwd": "${workspaceRoot}",
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "args": [
                "${workspaceRoot}/development.ini"
            ],
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput",
                "Pyramid"
            ]
        },
        {
            "name": "Watson",
            "type": "python",
            "request": "launch",
            "stopOnEntry": true,
            "pythonPath": "${config.python.pythonPath}",
            "program": "${workspaceRoot}/console.py",
            "cwd": "${workspaceRoot}",
            "args": [
                "dev",
                "runserver",
                "--noreload=True"
            ],
            "env": null,
            "envFile": "${workspaceRoot}/.env",
            "debugOptions": [
                "WaitOnAbnormalExit",
                "WaitOnNormalExit",
                "RedirectOutput"
            ]
        },
        {
            "name": "Attach (Remote Debug)",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceRoot}",
            "remoteRoot": "${workspaceRoot}",
            "port": 3000,
            "secret": "my_secret",
            "host": "localhost"
        }
    ]
}

{

    "version": "0.2.0",

    "configurations": [

        {

            "name": "Python",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "pythonPath": "${config.python.pythonPath}",

            "program": "${file}",

            "cwd": "${workspaceRoot}",

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput"

            ]

        },

        {

            "name": "PySpark",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "osx": {

                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"

            },

            "windows": {

                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit.cmd"

            },

            "linux": {

                "pythonPath": "${env.SPARK_HOME}/bin/spark-submit"

            },

            "program": "${file}",

            "cwd": "${workspaceRoot}",

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput"

            ]

        },

        {

            "name": "Python Module",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "pythonPath": "${config.python.pythonPath}",

            "module": "module.name",

            "cwd": "${workspaceRoot}",

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput"

            ]

        },

        {

            "name": "Integrated Terminal/Console",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "pythonPath": "${config.python.pythonPath}",

            "program": "${file}",

            "cwd": null,

            "console": "integratedTerminal",

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit"

            ]

        },

        {

            "name": "External Terminal/Console",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "pythonPath": "${config.python.pythonPath}",

            "program": "${file}",

            "cwd": null,

            "console": "externalTerminal",

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit"

            ]

        },

        {

            "name": "Django",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "pythonPath": "${config.python.pythonPath}",

            "program": "${workspaceRoot}/manage.py",

            "cwd": "${workspaceRoot}",

            "args": [

                "runserver",

                "--noreload"

            ],

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput",

                "DjangoDebugging"

            ]

        },

        {

            "name": "Flask",

            "type": "python",

            "request": "launch",

            "stopOnEntry": false,

            "pythonPath": "${config.python.pythonPath}",

            "program": "fully qualified path fo 'flask' executable. Generally located along with python interpreter",

            "cwd": "${workspaceRoot}",

            "env": {

                "FLASK_APP": "${workspaceRoot}/quickstart/app.py"

            },

            "args": [

                "run",

                "--no-debugger",

                "--no-reload"

            ],

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput"

            ]

        },

        {

            "name": "Flask (old)",

            "type": "python",

            "request": "launch",

            "stopOnEntry": false,

            "pythonPath": "${config.python.pythonPath}",

            "program": "${workspaceRoot}/run.py",

            "cwd": "${workspaceRoot}",

            "args": [],

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput"

            ]

        },

        {

            "name": "Pyramid",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "pythonPath": "${config.python.pythonPath}",

            "cwd": "${workspaceRoot}",

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "args": [

                "${workspaceRoot}/development.ini"

            ],

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput",

                "Pyramid"

            ]

        },

        {

            "name": "Watson",

            "type": "python",

            "request": "launch",

            "stopOnEntry": true,

            "pythonPath": "${config.python.pythonPath}",

            "program": "${workspaceRoot}/console.py",

            "cwd": "${workspaceRoot}",

            "args": [

                "dev",

                "runserver",

                "--noreload=True"

            ],

            "env": null,

            "envFile": "${workspaceRoot}/.env",

            "debugOptions": [

                "WaitOnAbnormalExit",

                "WaitOnNormalExit",

                "RedirectOutput"

            ]

        },

        {

            "name": "Attach (Remote Debug)",

            "type": "python",

            "request": "attach",

            "localRoot": "${workspaceRoot}",

            "remoteRoot": "${workspaceRoot}",

            "port": 3000,

            "secret": "my_secret",

            "host": "localhost"

        }

    ]
}



RE: Launch.json isn't working - nilamo - Mar-16-2017

There's a lot of formatting making it hard to read (next time, try right clicking and Paste Without Formatting), but it looks like it's just a config letting VS know how to run the script. I have no idea what that file should contain, since it only has meaning to VS. Try creating a new project, and copying the file over from that.

And you probably shouldn't ever need to touch it, that looks like setting the editor keeps track of so you don't have to setup a python environment every time you start VS.