How to run python3 code in VSCode? /bin/sh: 1: python: not found

≡放荡痞女 提交于 2021-01-27 07:22:37

问题


I'm trying to run a python file in VSCode using python3.

I know I can fix by simply setting to run using integrated terminal like it says in the microsoft vscode tutorial on python. However, I would like the program to print in the output tab and not take up the terminal window.

The standard coder runner launch.json looks like this;

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

I've tried to set my python path in VSCode in settings.json

...
"python.pythonPath": "python3",
"code-runner.executorMap": {
    "python3": "/usr/bin/python3"
}

I've also set an alias for python -> python3 (as my ubuntu 20.04 doesn't come with python2 anymore)

alias python="python3"

However, I keep getting the above error. Any Ideas?


回答1:


Nearly had it. This code

...
"python.pythonPath": "python3",
"code-runner.executorMap": {
    "python3": "/usr/bin/python3"
}

should be

...
"python.pythonPath": "python3",
"code-runner.executorMap": {
    "python": "/usr/bin/python3"
}


来源:https://stackoverflow.com/questions/61620036/how-to-run-python3-code-in-vscode-bin-sh-1-python-not-found

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