Python unzip large file - NotImplementedError: compression type 98

Python unzip large file - NotImplementedError: compression type 98

我正在使用以下 Python 代码来解压缩文件

import zipfile
zfile = zipfile.ZipFile(input_file_path)
zfile.extractall(output_path)

但是,当我尝试解压缩一个更大的文件时。它抛出以下错误。

NotImplementedError: compression type 98 (ppmd)

我该如何解决这个错误?

谢谢。

Python 的 zipfile 模块不支持 PPMd 压缩——参见 issue 14366(强调已添加):

I think we should add the ability to register new codecs. Support for PPMd, jpeg and WavPack is unlikely to emerge in the Python in the foreseeable future, but users of third-party libraries (such as PIL), will use the new codecs as needed.

只有两个选项:

  • 使用来自 Python 的外部 zip 程序和 subprocess 模块。 p7zip 程序可以很好地完成这项工作。

  • 修改 Python 以将 PPMd 支持添加到 zipfile 模块。

请记住,PPMd 是一种非常不常用的编解码器,因此大多数程序(包括常规 unzip)根本不支持它。