Code Runner does not work for Python in VsCode

喜你入骨 提交于 2020-06-29 03:49:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!