问题
I can run python files in cmd promt and Vscode terminal (cmd prompt). When I try to run any programme with Code runner ("code-runner.runInTerminal": false
), I get the following error:
[Running] python "c:\Users\MY PATH INCLUDING WHITESPACE\hello_world.py"
Python was not found but can be installed from the Microsoft Store: https://go.microsoft.com/fwlink?linkID=2082640
Here are the user settings (settings.json) I have tried:
"code-runner.executorMap": {
"python": "python",
},
"code-runner.executorMap": {
"python": "$pythonPath $fullFileName",
},
"code-runner.executorMap": {
"python": "$pythonPath -u $fullFileName",
},
..but I always get the same error.
It seems like the problem could be related to code runner, but could have something to do with the setup of python on my machine.
It could potentially have something to do with the fact I have two python files for the location of python.exe:
(base) C:\>where python
C:\Users\<user_name>\AppData\Local\Continuum\anaconda3\python.exe
C:\Users\<user_name>\AppData\Local\Microsoft\WindowsApps\python.exe
This is the only difference I can think of to another machine where this actually works, but can't be sure.
Any ideas what the issue could be?
回答1:
maybe try the following: Change the executormap to:
"code-runner.executorMap": {
"python": "\"$pythonPath\" $fullFileName",
}
Also you could try to give a concrete python path, maybe create a venv and try there:
"python.pythonPath": "venv/bin/python"
来源:https://stackoverflow.com/questions/61497103/code-runner-does-not-work-for-python-in-vscode