1

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?

linkedby
  • 148
  • 1
  • 8
  • I'm on Windows 10 – linkedby Jun 14 '22 at 17:30
  • 1
    If you don't find any answers here, there's Code Runner's [official issues page](https://github.com/formulahendry/vscode-code-runner/issues). Also I found [this picture](https://techdecodetutorials.com/wp-content/uploads/2021/07/5_20210710_153025_0004.png?ezimgfmt=ng:webp/ngcb1) of some Code Runner settings that should work for various languages including Python. – Random Davis Jun 14 '22 at 17:33

2 Answers2

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.

linkedby
  • 148
  • 1
  • 8
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

Gautam A20
  • 16
  • 5
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/33559101) – sim Jan 05 '23 at 13:10