skip to Main Content

I am trying to learn Python on Visual Studio Code and I have downloaded Python extensions but when I write a code and press run I see this

[Running] swift "c:UserswDesktoppython" 'swift' is not recognized as an internal or external command, operable program or batch file. [Done] exited with code=1 in 0.317 seconds

I tried to make sure that I have installed all python extensions and I was expecting the code to run

2

Answers


  1. Double check that your launch.json is fine. (.vscode/launch.json).

    If it doesnt exist, create it and put something like this inside it.

    {
        "configurations": [
            {
                "name": "Python: Current File",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal",
                "justMyCode": true
            }
        ]
    }
    

    Hope it helps. Also, i’ve noticed that it was trying to run swift, which is a bit odd, so yeah i think your launch.json just might be messed up. I can’t know for sure tho, so post it please

    Login or Signup to reply.
  2. The error message says you are running code with the Code Runner extension, which is incorrect. Please use the official extension Python to execute the script.

    enter image description here

    It would be helpful to follow this documentation.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search