如何关闭VsCode调试器中的“evaluation:plt.show()在3.00s秒后未完成”警告?

2024-05-17 05:43:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我经常通过在vscode调试器中绘制NumPy数组来调试python代码。 我经常花3秒钟以上的时间看一个情节。当我做vscode打印的时候 下面是长长的警告。这很烦人,因为我必须向上滚动很多 始终查看以前的调试输出。PYDEVD\u警告\u评估\u超时在哪里 变量我怎么关掉这个

为了完整起见,我在下面添加了警告,非常感谢您的帮助

Evaluating: plt.show() did not finish after 3.00s seconds. This may mean a number of things:

  • This evaluation is really slow and this is expected. In this case it's possible to silence this error by raising the timeout, setting the PYDEVD_WARN_EVALUATION_TIMEOUT environment variable to a bigger value.

  • The evaluation may need other threads running while it's running: In this case, it's possible to set the PYDEVD_UNBLOCK_THREADS_TIMEOUT environment variable so that if after a given timeout an evaluation doesn't finish, other threads are unblocked or you can manually resume all threads.

    Alternatively, it's also possible to skip breaking on a particular thread by setting a pydev_do_not_trace = True attribute in the related threading.Thread instance (if some thread should always be running and no breakpoints are expected to be hit in it).

  • The evaluation is deadlocked: In this case you may set the PYDEVD_THREAD_DUMP_ON_WARN_EVALUATION_TIMEOUT environment variable to true so that a thread dump is shown along with this message and optionally, set the PYDEVD_INTERRUPT_THREAD_TIMEOUT to some value so that the debugger tries to interrupt the evaluation (if possible) when this happens.


Tags: andthetoin警告environmentistimeout
2条回答

如果你想超越警告,你可以这样做:

在本文件第28.6.3点中,您可以这样做: https://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings

如果链接在将来死亡,下面是代码

import warnings

def fxn():
    warnings.warn("deprecated", DeprecationWarning)

with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    fxn()

您应该准备好使用简单的复制粘贴

If找到了一种方法来调整launch.json,它解决了这个问题

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "env": {"DISPLAY":":1",
                    "PYTHONPATH": "${workspaceRoot}",
                    "PYDEVD_WARN_EVALUATION_TIMEOUT": "500"},
            "cwd": "${workspaceFolder}",
            "console": "integratedTerminal"
        }
    ]
}

相关问题 更多 >