简体   繁体   English

vscode“在不调试的情况下运行”不打开 Python 调试控制台

[英]vscode "Run Without Debugging" doesn't open Python Debug Console

VSCode's "Run Without Debugging" runs the python file (I can tell from time passing) but it doesn't open any panel/terminal to show the output. VSCode 的“无需调试即可运行”运行 python 文件(我可以从时间过去看出),但它没有打开任何面板/终端来显示 output。

I have uninstalled/reinstalled the Microsoft python extension, and run the above experiment outside of any workspace, in a brand new directory with a single "test.py" file, after quitting/reopening VSCode.我已经卸载/重新安装了 Microsoft python 扩展,并在退出/重新打开 VSCode 后,在带有单个“test.py”文件的全新目录中,在任何工作区之外运行上述实验。

How do I get VSCode to open the "Python Debug Console" upon "Run Without Debugging"?如何让 VSCode 在“运行而不调试”时打开“Python 调试控制台”?

您可以手动在setting.json中设置pythonpath的内容。

"python.pythonpPath":"the location of your python.exe" #Note that python.EXE is used here. If you use conda environment, the default configuration may be set to pythonw.exe

I found another possible solution.我找到了另一种可能的解决方案。

You can specify the shell in setting.json by adding the following code:您可以通过添加以下代码在setting.json中指定shell:

"terminal.integrated.shell.windows":"C:\\WINDOWS\\system32\\cmd.exe",

Of course, this method is outdated, and we will also receive warnings (but it will not affect its effectiveness):当然,这种方法已经过时了,我们也会收到警告(但不会影响其有效性):

在此处输入图像描述

According to the update of document , we can name the terminal and specify the default terminal in the following way:根据文档的更新,我们可以通过以下方式命名终端并指定默认终端:

    {
  "terminal.integrated.profiles.windows": {
    "My PowerShell": {
      "path": "pwsh.exe",
      "args": [
         "-noexit",
         "-file",
         "${env:APPDATA}\PowerShell\my-init-script.ps1"
      ]
    }
  },
  "terminal.integrated.defaultProfile.windows": "My PowerShell"
}

在菜单栏的顶部有一个名为“终端”的选项卡单击它,然后点击新终端

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM