1

Can you extract .7z files using Python without having to install any additional modules? I'm trying to keep my dependencies to a minimum where ever i can. I know you can use shutil to extract .zip and other archives but i don't think it supports .7z?

[edit by lhasadad] this appears to be duplicate of:

extract 7z file using python 3

LhasaDad
  • 1,786
  • 1
  • 12
  • 19
  • Python is capable of reading files byte-by-byte. It also supports enough general programming ability to be Turing complete. So yes, it is *possible*. – Mark Jun 09 '22 at 00:45
  • @Mark Which standard libraries have native support for extracting .7z files? – thisismy-stackoverflow Jun 09 '22 at 00:50
  • `shutil` uses C/C++ libraries to uncompress files. See doc [get_unpack_formats](https://docs.python.org/3/library/shutil.html#shutil.get_unpack_formats). So it has some dependencies too. The same way you could use `subprocess` to use program `7zip` to uncompress `.7z` and this will be also depends on C/C++ library/program. – furas Jun 09 '22 at 00:50
  • @Mark I could of phrased that better, to be fair. I was wondering if I could use the standard libraries included with Python and not have to 'pip install' other modules in order to extract a 7z archive. – Happy Bunny Jun 09 '22 at 00:51
  • for .7z you would have to write all code from scratch. – furas Jun 09 '22 at 00:53
  • 2
    @LhasaDad What's up with that edit instead of the standard close vote/flag? – Kelly Bundy Jun 09 '22 at 01:14
  • @KellyBundy sorry if that was incorrect way to address. Was trying to figure right way to close as duplicate. My bad there. Missed the duplicate item in the flag option. had checked but missed it (older eyes ;-) ) – LhasaDad Jun 10 '22 at 03:16

0 Answers0