gpt4 book ai didi

python - 你如何在 Linux 终端上抑制 Python DeprecationWarnings?

转载 作者:IT王子 更新时间:2023-10-29 00:52:32 25 4
gpt4 key购买 nike

我使用 easy_install 安装了 i18ndude(一个在 Plone 中使用的国际化实用程序)。

当我尝试在我的终端上运行实用程序 i18ndude 时,我得到:

/usr/local/lib/python2.6/dist-packages/i18ndude-3.1.2-py2.6.egg/i18ndude/odict.py:7: DeprecationWarning: object.__init__() takes no parameters
dict.__init__(self, dict)

从命令行调用该实用程序时如何抑制这些警告消息?可能吗?我知道理论上我应该安装其他 Python 解释器,并从中调用 i18ndude,但我想要一种更简单的方法(比如参数或类似的东西)。

顺便说一句,我正在使用来自 Plone official sitei18ndude 脚本.

最佳答案

可以使用重定向,但它会抑制发送到该“流”的所有消息;例如

i178ndude 2>/dev/null

将流 2 发送到空设备(通常是程序的标准错误,但弃用警告可以发送到其他流)。这是“即使您不知道如何修复它”的修复方法。确实有一个选项,-W,可以像这样使用:-W ignore::DeprecationWarning 或简单地 -W ignore 忽略所有警告。你可以编写一个脚本来调用程序中的 python 解释器,或者更逻辑地修改 prog 的 #! 类似 #!/usr/bin/env python -W ignore: :弃用警告

关于python - 你如何在 Linux 终端上抑制 Python DeprecationWarnings?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3063414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com