centos2015 2022-09-15 10:15 采纳率: 100%
浏览 135
已结题

python py7zr 模块问题

使用python 解压7z 压缩包
已安装py7zr :pip install py7zr

python代码如下

import py7zr
import os
with py7zr.SevenZipFile('result.7z', mode='r',password='1234') as z:
 z.extractall()

运行代码,报错较多

PS G:\python\test> & D:/python3.6/python.exe g:/python/test/web.py
Traceback (most recent call last):
  File "D:\python3.6\lib\site-packages\bcj\__init__.py", line 12, in <module>
    from ._bcj import (
ModuleNotFoundError: No module named 'bcj._bcj'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\python3.6\lib\site-packages\bcj\__init__.py", line 28, in <module>
    from ._bcjfilter import (
ImportError: cannot import name 'IA64Decoder'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "g:/python/test/web.py", line 1, in <module>
    import py7zr
  File "D:\python3.6\lib\site-packages\py7zr\__init__.py", line 45, in <module>
    from py7zr.py7zr import ArchiveInfo, FileInfo, SevenZipFile, is_7zfile, pack_7zarchive, unpack_7zarchive
  File "D:\python3.6\lib\site-packages\py7zr\py7zr.py", line 44, in <module>
    from py7zr.archiveinfo import Folder, Header, SignatureHeader
  File "D:\python3.6\lib\site-packages\py7zr\archiveinfo.py", line 36, in <module>
    from py7zr.compressor import SevenZipCompressor, SevenZipDecompressor
  File "D:\python3.6\lib\site-packages\py7zr\compressor.py", line 32, in <module>
    import bcj  # type: ignore  # noqa
  File "D:\python3.6\lib\site-packages\bcj\__init__.py", line 44, in <module>
    raise ImportError(msg)
ImportError: pybcj module: Neither C implementation nor Python implementation can be imported.

我去dos窗口尝试了 py7zr命令,依然报错

D:\python3.6\Scripts>py7zr.exe
Traceback (most recent call last):
  File "d:\python3.6\lib\site-packages\bcj\__init__.py", line 12, in <module>
    from ._bcj import (
ModuleNotFoundError: No module named 'bcj._bcj'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\python3.6\lib\site-packages\bcj\__init__.py", line 28, in <module>
    from ._bcjfilter import (
ImportError: cannot import name 'IA64Decoder'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\python3.6\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "d:\python3.6\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "D:\python3.6\Scripts\py7zr.exe\__main__.py", line 4, in <module>
  File "d:\python3.6\lib\site-packages\py7zr\__init__.py", line 45, in <module>
    from py7zr.py7zr import ArchiveInfo, FileInfo, SevenZipFile, is_7zfile, pack
_7zarchive, unpack_7zarchive
  File "d:\python3.6\lib\site-packages\py7zr\py7zr.py", line 44, in <module>
    from py7zr.archiveinfo import Folder, Header, SignatureHeader
  File "d:\python3.6\lib\site-packages\py7zr\archiveinfo.py", line 36, in <modul
e>
    from py7zr.compressor import SevenZipCompressor, SevenZipDecompressor
  File "d:\python3.6\lib\site-packages\py7zr\compressor.py", line 32, in <module
>
    import bcj  # type: ignore  # noqa
  File "d:\python3.6\lib\site-packages\bcj\__init__.py", line 44, in <module>
    raise ImportError(msg)
ImportError: pybcj module: Neither C implementation nor Python implementation ca
n be imported.

初入python,百度许久没有结果过……

  • 写回答

2条回答 默认 最新

  • centos2015 2022-09-15 15:22
    关注

    找到方法了,py7zr 支持以下算法 ,这里报错是提示没有 BCJ这个算法模块,
    直接安装就可以了:pip install bcj-cffi

    compress
    LZMA2
    
    LZMA
    
    Bzip2
    
    Deflate
    
    Copy
    
    PPMd
    
    Zstandard
    
    crypt
    7zAES
    
    Filters
    Delta
    
    BCJ(X86,ARMT,ARM,PPC,SPARC,IA64)
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 9月23日
  • 已采纳回答 9月15日
  • 创建了问题 9月15日

悬赏问题

  • ¥20 Html备忘录页面制作
  • ¥15 黄永刚的晶体塑性子程序中输入的材料参数里的晶体取向参数是什么形式的?
  • ¥20 数学建模来解决我这个问题
  • ¥15 计算机网络ip分片偏移量计算头部是-20还是-40呀
  • ¥15 stc15f2k60s2单片机关于流水灯,时钟,定时器,矩阵键盘等方面的综合问题
  • ¥15 YOLOv8已有一个初步的检测模型,想利用这个模型对新的图片进行自动标注,生成labellmg可以识别的数据,再手动修改。如何操作?
  • ¥30 NIRfast软件使用指导
  • ¥20 matlab仿真问题,求功率谱密度
  • ¥15 求micropython modbus-RTU 从机的代码或库?
  • ¥15 django5安装失败