Python 2.7: Compressing data with the XZ format using the “lzma” module

前端 未结 2 1450
南方客
南方客 2021-01-12 20:37

I\'m experimenting with the lzma module in Python 2.7.6 to see if I could create compressed files using the XZ format for a future project that will make use of it. My code

2条回答
  •  情深已故
    2021-01-12 21:12

    In my case (Ubuntu/Mint), in order to use the lzma module with Pyhton 2.7, I installed backports.lzma directly with pip (I have not used github), with sudo or root user:

    pip2 install backports.lzma
    

    FYI pip2 has the --user option that doesn't require superuser permissions and installs the module for the local user only, but I have not tested this.

    First than performing the pip installation, you have also to install, with your package manager, one mandatory dependency: the library liblzma.

    In my case the package names were liblzma5 andliblzma-dev but package names may differ between Linux distro/releases.

    P.s: I also repeated the same operation with success with conda on a different Linux environment (Unknown cluster distro):

    conda install backports
    conda install backports.lzma --name pyEnvName
    

    Hope useful

提交回复
热议问题