1

I have a program that requires unzipping of a .xz compressed archive, How to decompress a .xz file which has multiple folders/files inside, in a single go?. I have read that this can be achieved by using lzma via pip install pyliblzma however it seems that this is broken on Windows when installing via pip.

Collecting pyliblzma
Using cached https://files.pythonhosted.org/packages/17/48/5292ade507dafe573360560ba53783395587dc42eb32b347feb2ac70fc6b/pyliblzma-0.5.3.tar.bz2
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\ben\appdata\local\temp\pip-install-_hmrno\pyliblzma\setup.py", line 48, in <module>
    shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True).stdout.read():
  File "c:\python27\lib\subprocess.py", line 347, in __init__
    raise ValueError("close_fds is not supported on Windows "
ValueError: close_fds is not supported on Windows platforms if you redirect stdin/stdout/stderr

I have also tried pip install pylzma but this requires the Visual Studio C++ compiler for Python building 'pylzma' extension error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27

As my program is portable and shared between users, I want to try and stay away from making them install separate binaries for use with the program.

Is there another way of exacting .xz archives in Python2.7 without using lzma, or alternatively a way to get a working version of lzma via pip install?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
jerrythebum
  • 330
  • 1
  • 6
  • 17

1 Answers1

0

I managed to get around my problem by using a portable version of 7zip and using its command line interface to extract the files.

params = ["7zG.exe", "x", "my_filename.xz", "-ooutputdir\\"]
p = Popen(params, stdout=subprocess.PIPE)
jerrythebum
  • 330
  • 1
  • 6
  • 17