There is a much easier way to run Python, and it doesn't need any configuration:
- Install the Code Runner Extension.
- Open the Python code file in Text Editor.
- To run Python code:
- use shortcut Ctrl + Alt + N
- or press F1 and then select/type Run Code,
- or right click the Text Editor and then click Run Code in the editor context menu
- or click the Run Code button in the editor title menu
- or click Run Code button in the context menu of file explorer
- To stop the running code:
- use shortcut Ctrl + Alt + M
- or press F1 and then select/type Stop Code Run
- or right click the Output Channel and then click Stop Code Run in the context menu
If you want to add the Python path, you could go to File → Preference → Settings, and add the Python path like below:
"code-runner.executorMap":
{
"python": ""C:\Program Files\Python35\python.exe" -u"
}
In case you have installed the Python extension and manually set your interpreter already, you could configure your settings.json file as follows:
{
"python.pythonPath": "C:\\python36\\python36.exe",
"code-runner.executorMap":
{
"python": "$pythonPath -u $fullFileName"
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…