繁体   English   中英

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

[英]I can't run code or debug of my python file in vscode

错误是这样说的:

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' 为面临相同问题的人添加

我遇到了同样的问题,我认为这可能是由于导入了太多以某种方式相互冲突的配置造成的。 当我收到错误时,我点击了“查看 json”文件的选项。 从那里,我基本上清除了文件并删除了所有引用 python 的行。 所以它就像一个空白的设置文件。 我关闭它,保存它,然后再次运行我的代码。 这一次,VSCode 提示我选择环境。 我选择了像这样列出的“Python”,代码运行得很好。

暂无
暂无

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

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