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

时间:2017-11-15 11:52:03

标签: 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}

我的' Python Attach'的设置在launch.json中看起来像这样:

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

看起来有些东西不见了。我意识到没有调试选项,但我不知道如何修复它。它曾经在更新之前正常工作。有什么帮助吗?

2 个答案:

答案 0 :(得分:1)

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

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

此外,对于我错误的/ etc / hosts配置导致问题'错误:listen eaddrnotavail'添加面对同一问题的人

答案 1 :(得分:0)

我遇到了同样的问题,我认为这可能是由于导入太多配置导致某种彼此冲突造成的。

当我收到错误时,我点击了“查看json”文件的选项。从那里开始,我基本清除了文件并删除了所有引用python的行。所以它就像一个空白的设置文件。我关闭它,保存它然后再次运行我的代码。

这一次,VSCode提示我选择环境。我选择了像这样列出的“Python”,代码运行得很好。

相关问题