2

I've installed Python 3.10.5 on my Windows 10 machine. Works splendidly running a file by writing "python file.py". What I can't do though, is to get the extension code runner to run python files through the hotkey ctrl + b. I've reinstalled Python (made sure to check PATH). Rebooted the computer and reinstalled code runner.

If I change no settings I get this error:

"/usr/bin/python3: The term '/usr/bin/python3' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

I found this similar thread: Code Runner does not work for Python in VsCode

After changing the code in settings.json to

"code-runner.executorMap": {
    "python": "\"$pythonPath\" $fullFileName",
}

I get the error:

1 | … Data\Local\Programs\Python\Python310\python.exe" "c:\lekspel\test.py" | ~~~~~~~~~~~~~~~~~~~~ | Unexpected token '"c:\lekspel\test.py"' in expression or statement.

adding in a "-u" returns this error:

Unexpected token '-u' in expression or statement.

Anyone got a clue how to sort this out?

2
  • I'm on Windows 10 Commented Jun 14, 2022 at 17:30
  • 1
    If you don't find any answers here, there's Code Runner's official issues page. Also I found this picture of some Code Runner settings that should work for various languages including Python. Commented Jun 14, 2022 at 17:33

2 Answers 2

1

I solved it by doing a fresh install of vscode, deleting my settings in roaming. Not an optimal solution by any means, but got it out of the way at least.

Sign up to request clarification or add additional context in comments.

Comments

0

got the same error. it was because i added "py" to path during installation setup (check by typing "py" in terminal if it opens python) so coderunner wasn't able to run python with "python" keyword, anyway try the following solution and tell me if it works:

1.Go to extensions

2.Right click -> extension settings

3.Edit settings in Json for any option settings of coderunner

4.change "python -u" to "py -u" like this

5.save json file with crl+s.

Run code again

tell me if it works for you. here mine worked like this

1 Comment

This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. To get notified when this question gets new answers, you can follow this question. Once you have enough reputation, you can also add a bounty to draw more attention to this question. - From Review

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.