#๐Ÿ”’ What type do I use in a VS Code launch config in order to run exe files?

16 messages ยท Page 1 of 1 (latest)

earnest plover
#

I have a project that requires me to convert the Python file to a exe file using pyinstaller -F main.py.
I run the aforementioned command in the terminal and I am able use the exe as intended.
However, when I try to set up a VS Code launch config which automatically runs the command and then runs the exe, I am unable to find a suitable launch type to run the exe file. What type do I use so that the exe file can be run without issues?

launch.json:

{
    "configurations": [
        {
            "name": "Launch",
            "type": "debugpy", //Cannot use this type as exe files cannot be run by the Python debugger (obviously)
            "request": "launch",
            "args": [],
            
            "cwd": "${workspaceRoot}",
            
            "program": "${workspaceRoot}/dist/main.exe",
            "preLaunchTask": "Package App",
            
          }
        
    ]
}

tasks.json:

{
    "tasks": [
      {
        "type": "shell",
        "label": "Package App",
        "command": "pyinstaller -F  main.py", 
        "args": [],
        "options": {
          "cwd": "${workspaceRoot}"
        },
        "problemMatcher": ["$python"],
        "group": {
          "kind": "build",
          "isDefault": true,
        },
        "detail": "Task generated by Debugger."
      }
    ],
    "version": "2.0.0"
  }
dusk hemlockBOT
#

@earnest plover

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

earnest plover
#

Please ping me when replying

sonic moon
earnest plover
sonic moon
#

personally I'd just recommend not using pyinstaller though TPF_02_Shrug

sonic moon
#

do not pack it into an exe

earnest plover
#

oh
can't avoid it in this case

#

but will keep it in mind

earnest plover
#
{
    "key": "ctrl+h",
    "command": "workbench.action.tasks.runTask",
    "args": "Run App"
  }
  

doesn't seem to work for me

sonic moon
#

not sure, never used tasks myself

dusk hemlockBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.