gpt4 book ai didi

python - zipimport.ZipImportError : bad local file header caused by zip caching bug?

转载 作者:行者123 更新时间:2023-12-05 07:47:07 27 4
gpt4 key购买 nike

我正在尝试确定 python 使用的 zip 缓存机制是否仍然存在错误。原因是因为我正在运行的 python 代码将(看似)随机失败并显示 zipimport.ZipImportError: bad local file header

它可能运行良好,然后当它尝试导入我安装的自定义模块时突然出现 ZipImportError(这可能发生在它已经在执行)。我没有在应用程序运行时更改自定义模块的 egg 文件,所以我有点难过。

使用谷歌搜索有关此错误的帮助 an old mailing list thread哪个州

This might be due to:

http://bugs.python.org/issue856103

Specifically, zipimport's caching doesn't notice that it's not working on the same zipfile any more. easy_install is supposed to have some code in it to clear out the zipimport cache, but there is some possibility that it could have two versions of the path in there on a case-insensitive filesystem (e.g. Windows), and only one of them is getting cleared. Dunno if that's the case or not, but it might be something to look into. You could always stick a debugging print in the uncache_zipdir function and see if there's any correlation between what it's doing and when you're getting the error.

我不清楚链接错误的解决方案。

我认为此时解决我的问题的唯一方法是将我的自定义模块标记为 zip_safe=false。除非有某种方法可以禁用 zip 缓存或类似的东西?

最佳答案

我从未找到此问题的原因或修复方法,但我将我的模块更改为使用 zip_safe=false 并阻止了问题再次发生。就我而言,这已经足够了。

关于python - zipimport.ZipImportError : bad local file header caused by zip caching bug?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40026777/

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