2

My code is as follows (from here: Example of how to use PyLZMA)

import py7zlib
...
#filename.__class__ is <class 'django.core.files.uploadedfile.InMemoryUploadedFile'>
archive = py7zlib.Archive7z(filename)
data = archive.getmember(archive.getnames()[0]).read()

The error that I get is:

*** ValueError: data error during decompression

The archive I am testing with is a driver compressed in 7z downloaded from the manufacturer's website. I have also used 7zip to create a 7z archive to test with, but I get the same result.

martineau
  • 119,623
  • 25
  • 170
  • 301
A G
  • 997
  • 2
  • 18
  • 36
  • From experience it is best to first try to use py7zlib to compress something, and then "immediately" to uncompress it. this will give you an idea of how to use the code, I didn't do this with py7zlib - but with other libraries – Noam Rathaus Nov 26 '13 at 13:55
  • I am experiencing the same problem. Could you figure it out? – user3820991 Apr 22 '15 at 16:03
  • I just tried to recreate the issue, however without the original file, I can't replicate this issue. I just tried with a self generated 7z file and I get `py7zlib.FormatError: not a 7z file`. With a driver file, it seems to work. – A G Apr 23 '15 at 11:03

1 Answers1

0

I suggest you open your file first, then use 'py7zlib' package. I have used this method to read the file successfully.

content=open(filename,"rb")
archive = py7zlib.Archive7z(content)
data = archive.getmember(archive.getnames()[0]).read()
frlan
  • 6,950
  • 3
  • 31
  • 72
DoubleQueens
  • 95
  • 1
  • 10