如何将 -Xfrozen_modules=off 传递给 python 以禁用冻结模块?

HSH*_*ATA 10 python python-3.x

在 VS 上运行 python 脚本会输出此错误。如何将 -Xfrozen_modules=off 传递给 python 以禁用冻结模块?

外壳的片段

我试图将 python 版本从 3.6 更新到 3.11,然后开始看到此消息。

小智 11

如果您使用 VS Code,您可以添加"pythonArgs": ["-Xfrozen_modules=off"]到 中的调试配置launch.json,如下所示:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python (Xfrozen=off)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "pythonArgs": ["-Xfrozen_modules=off"]
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

GitHub 问题fabioz/PyDev.Debugger/issues/213中有一些额外的上下文。