我有一个程序,需要解压缩的.xz压缩档案,How to decompress a .xz file which has multiple folders/files inside, in a single go?。我读到这可以通过pip install pyliblzma使用lzma来实现,但是在通过pip安装时,这似乎在Windows上被破坏了。
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我也尝试过pip install pylzma,但这需要用于Python building 'pylzma' extension error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27的Visual Studio C++编译器
因为我的程序是可移植的,并且可以在用户之间共享,所以我希望尽量避免让他们安装单独的二进制文件来与程序一起使用。
在Python2.7中,有没有其他方法可以在不使用lzma的情况下提取.xz归档文件,或者通过pip install获得lzma的工作版本?
发布于 2018-08-03 18:22:05
通过使用7zip的可移植版本并使用其命令行界面提取文件,我设法解决了我的问题。
params = ["7zG.exe", "x", "my_filename.xz", "-ooutputdir\\"]
p = Popen(params, stdout=subprocess.PIPE)https://stackoverflow.com/questions/51655361
复制相似问题