error opening archive(7z) files in python when made by 7zip

1.2k views Asked by At

I have been learning python got the basics down

to get better I have been trying to create a program to open archive files, not create just open.

I can easily create and open 7z files however when the archive is created with 7zip it does not open it, anyone know why and how I can open files created by 7zip

  data = b"Insert Data Here"
  with lzma.open("file.7z", "w") as f:
    f.write(data)


  with lzma.LZMAFile("file.7z") as f:
        fc =f.read()
        print(fc)

the traceback

Traceback (most recent call last):
  File "<string>", line 420, in run_nodebug
  File "C:\Users\<name>\Documents\Py\decompression.py", line 20, in <module>
    main()
  File "C:\Users\<name>\Documents\Py\decompression.py", line 15, in main
    fc =f.read()
  File "C:\Python33\lib\lzma.py", line 291, in read
    return self._read_all()
  File "C:\Python33\lib\lzma.py", line 244, in _read_all
    while self._fill_buffer():
  File "C:\Python33\lib\lzma.py", line 238, in _fill_buffer
    self._buffer = self._decompressor.decompress(rawblock)
_lzma.LZMAError: Input format not supported by decoder
0

There are 0 answers