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

标签 python python-2.7 setuptools

我正在尝试确定 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/

相关文章:

python - PySpark 应用程序失败,出现 java.lang.OutOfMemoryError : Java heap space

python - 使用 setup.py 安装时未复制 __init__ 模块

python - 如何从 setup_requires 依赖项覆盖 setuptools 命令?

python - 奇怪的 ~150ms 启动惩罚使用 python setuptools

python - 我怎样才能在我的 python 代码中避免这个错误

python - 如何在 Pandas 句子列中使用自动更正

python - 使用 turtle.onclick() 改变一个变量

python - pandas:将数据帧减少到仅出现特定的事件链

python - Python 中 numpy 数组和多维列表的区别?

python - PostgreSQL 日期时间类型的最佳数据类型