The pylzma library is a requirement for another tool that I would like to use. I am new to python and programming and have a few questions:

I have already followed the procedure to download and install pylzma from the following site since it seems to be the easiest: https://code.google.com/p/threadzip/wiki/InstallingPylzma

But I get stuck at the byte compile py7zlib part.

How do I byte compile py7zlib?

When I check the documentation on the authors page http://www.joachim-bauch.de/projects/pylzma/ and go to the designated folder I see the following files:

In the /tmp/pylzma-0.4.6/build/lib.linux-i686-2.7 folder I see: py7lib.py py7zlib.pyc pylzma.so

But no the "py7zlib.pwd" as stated on the authors page however I do see the "py7zlib.pyc" as stated on the original page listed.

Do I still need to compile this bytecode?

When I "import python" in at the python prompt I see nothing, no feedback or error. How do I check to see if this has been correctly imported and that I have installed this library correctly?

  • import python at the Python prompt should print an error message: ImportError: No module named python (after a couple of lines of traceback info). But what happens if you do import pylzma at the python prompt? – PM 2Ring Dec 21 '14 at 8:56
  • You are correct - that is a mistake I meant to say "import pylzma" – S.Poon Dec 21 '14 at 8:57
  • What is the other tool? Are you sure it is dependent on pylzma and not on the newer lzma module? which distro are you on? – Anthon Dec 21 '14 at 8:58
  • SWFZip is the other tool and I am on Ubuntu. – S.Poon Dec 21 '14 at 9:01
  • You don't get any feedback in the Python interactive interpreter with a successful import. But after importing pylzma if you do help(pylzma) you should get some helpful info. – PM 2Ring Dec 21 '14 at 9:01

Those are several questions so lets start at the beginning:

  1. I don't know why instructions for Python 2.6 from 2012 seem the simplest, but in general you should:

    • install using your package manager e.g on Debian/Ubuntu sudo apt-get install python-lzma (this is the backport of the the standard lzma module that appeared in Python3.3)
    • or install from PyPI using pip (which has to be installed only once):

      sudo apt-get install python-pip
      pip install pylzma

    Both these methods allow you to deinstall, something starting from the tar doesn't guarantee. Using pip normally gives you a more up-to-date package, but cannot handle system library dependencies (so you might have to install the package liblzma5 if not already installed.

  2. You don't normally bytecompile explicitly, at the latest on first use this is done, or during setup. But python works ok with .py files even if it cannot write the .pyc on first use (it just starts slower).

  3. I wonder why import python at the python prompt doesn't give an error. On my system it does, as there is no file python.py. To test if you have pylzma you could follow the instructions on the outdated page you refer to:

    >>> import pylzma
    >>> import py7zlib

Using pip I got version 0.4.6 of Igor Pavlov's bindings

  • I have a fresh Ubuntu 14.10 version. Just created this VM. – S.Poon Dec 21 '14 at 17:55
  • user@ubuntu:~$ python Python 2.7.8 (default, Oct 20 2014, 15:05:19) [GCC 4.9.1] on linux2 – S.Poon Dec 21 '14 at 17:57
  • Both python-lzma and python-pip installed correctly. There appears to be no error messages. – S.Poon Dec 21 '14 at 18:00
  • When I do pip install pylzma that is when I have problems: creating build/temp.linux-x86_64-2.7/src/compat x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -DWITH_COMPAT=1 -DPYLZMA_VERSION="0.4.6" -Isrc/sdk -I/usr/include/python2.7 -c src/pylzma/pylzma.c -o build/temp.linux-x86_64-2.7/src/pylzma/pylzma.o – S.Poon Dec 21 '14 at 18:00
  • 1
    UnsupportedPlatformWarning: Multithreading is not supported on the platform "linux2", please contact mail@joachim-bauch.de for more informations. please contact mail@joachim-bauch.de for more informations.""" % (sys.platform), UnsupportedPlatformWarning) src/pylzma/pylzma.c:26:20: fatal error: Python.h: No such file or directory #include <Python.h> ^ compilation terminated. error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 – S.Poon Dec 21 '14 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.