Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我无法在vscode中运行代码或调试python文件_Python_Visual Studio Code - Fatal编程技术网

我无法在vscode中运行代码或调试python文件

我无法在vscode中运行代码或调试python文件,python,visual-studio-code,Python,Visual Studio Code,错误是这样的: There was an error in starting the debug server. Error = {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":3000} launch.json中我的“Python Attach”的设置如下所示: { "name": "Python: Attach",

错误是这样的:

There was an error in starting the debug server. Error = {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":3000}
launch.json中我的“Python Attach”的设置如下所示:

    {
        "name": "Python: Attach",
        "type": "python",
        "request": "attach",
        "localRoot": "${workspaceRoot}",
        "remoteRoot": "${workspaceRoot}",
        "port": 3000,
        "secret": "my_secret",
        "host": "localhost"
    },

好像少了什么东西。我意识到没有调试选项,但我不知道如何修复它。它在更新之前工作正常。有什么帮助吗?

您可以在调试期间通过“替换”或“选择”使用以下简单设置

{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${file}",
"pythonPath": "${config:python.pythonPath}",
"debugOptions": [
    "RedirectOutput"
]
}

此外,对于我来说,错误的/etc/hosts配置导致了“error:listen eaddrnotavail”问题,为面临相同问题的人添加该问题,我遇到了相同的问题,我认为可能是由于导入了太多的配置,这些配置之间存在冲突。当我收到错误时,我点击了查看json文件的选项。从那里,我基本上清除了文件,删除了所有引用python的行。所以它就像一个空白的设置文件。我关闭它,保存它,然后再次运行我的代码。这一次,VSCode提示我选择环境。我选择了Python,它的列表就是这样,代码运行得很好。

您正在将调试器附加到端口3000上。您的应用程序是否在该端口上运行?同时,将调试器附加到正在运行的应用程序也会出现问题。您可能想考虑使用调试器启动应用程序,而不是使用IPDB或其他任何程序。debugger@OluwafemiSule不,我不知道港口是什么时候到那里的。我从不在网上调试。您知道在“调试控制台”中调试的正确设置是什么吗?