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

标签 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",
        "type": "python",
        "request": "attach",
        "localRoot": "${workspaceRoot}",
        "remoteRoot": "${workspaceRoot}",
        "port": 3000,
        "secret": "my_secret",
        "host": "localhost"
    },

好像少了点什么。我意识到没有 debugOption 但我不知道如何修复它。更新之前一直工作得很好。有什么帮助吗?

最佳答案

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

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

此外,对于我来说,错误的/etc/hosts 配置导致了问题“error:listen eaddrnotavail”,为面临相同问题的人添加

关于python - 我无法在 vscode 中运行代码或调试 python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47306704/

相关文章:

c# - Windows 操作系统中无法访问的 IP 套接字关闭时间

python - 无法在 OS X 上将 MySQL 导入到 python 中

visual-studio-code - 模块 '"typeorm "' has no exported member ' 列', 'PrimaryGeneratedColumn', 'Entity' - Visual Studio Code

python - Bs4 按类别查找 p 标签

python - 在迭代中修改列表和字典,为什么它在字典上失败?

css - 颜色值突出显示

android - 无法连接到 avd

visual-studio-code - 为什么我的代码输出最后会出错?

tfs - 无法使用 Visual Studio 代码连接到 tfvc

python - 如何从 python 中的字符串中删除整个单词?