Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Launch.json isn't working
#1
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.
Reply
#2
what is launch.json???
how about showing the code?
Reply
#3
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?
Reply
#4
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.
Reply
#5
{
    "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"

        }

    ]
}
Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Launch Python IDLE Shell from terminal Pavel_47 5 1,255 Feb-17-2023, 02:53 PM
Last Post: Pavel_47
  Launch Windows Application OEMS1 0 2,131 Mar-26-2021, 07:42 PM
Last Post: OEMS1
Photo Python won`t launch error newbieee 0 1,775 Feb-02-2021, 11:51 PM
Last Post: newbieee
  Launch another python command without waiting for a return. SpongeB0B 13 10,991 Jun-18-2020, 10:45 AM
Last Post: Yoriz
  error message on program launch DJPY1175 0 1,752 Jun-10-2019, 08:40 AM
Last Post: DJPY1175
  [split] Python won't launch Nikmartin 1 2,326 May-12-2019, 11:58 PM
Last Post: micseydel
  Pyinstaller exe won't launch after crash kainev 0 2,618 May-11-2019, 06:06 PM
Last Post: kainev
  How to launch a program through python script - Mac OS Mojave Aurimas 2 2,825 May-11-2019, 10:20 AM
Last Post: kritesh
  launch .exe from python script in windows hary 8 59,594 Mar-21-2017, 10:25 AM
Last Post: Ofnuts
  Python Launch Options Flexico 6 7,091 Dec-07-2016, 06:58 AM
Last Post: Flexico

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020