[Solved] Error in installing backups.lzma for Python on Linux

Error in installing backups.lzma for Python on Linux

pip3.9 install backports.lzma

Error Message:

Running setup.py install for backports.lzma … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3.9 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’; file=’”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’;f = getattr(tokenize, ‘”’”‘open’”’”’, open)(file) if os.path.exists(file) else io.StringIO(’”’”‘from setuptools import setup; setup()’”’”’);code = f.read().replace(’”’”’\r\n’”’”’, ‘”’”’\n’”’”’);f.close();exec(compile(code, file, ‘”’”‘exec’”’”’))’ install –record /tmp/pip-record-tcqknwy3/install-record.txt –single-version-externally-managed –compile –install-headers /usr/local/python3.9/include/python3.9/backports.lzma
cwd: /tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/
Complete output (21 lines):
This is backports.lzma version 0.0.14
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.9
creating build/lib.linux-x86_64-3.9/backports
copying backports/init.py -> build/lib.linux-x86_64-3.9/backports
creating build/lib.linux-x86_64-3.9/backports/lzma
copying backports/lzma/init.py -> build/lib.linux-x86_64-3.9/backports/lzma
running build_ext
building ‘backports.lzma._lzma’ extension
creating build/temp.linux-x86_64-3.9
creating build/temp.linux-x86_64-3.9/backports
creating build/temp.linux-x86_64-3.9/backports/lzma
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/python3.9/include -I/root/include -I/opt/local/include -I/usr/local/include -I/usr/local/python3.9/include/python3.9 -c backports/lzma/_lzmamodule.c -o build/temp.linux-x86_64-3.9/backports/lzma/_lzmamodule.o
backports/lzma/_lzmamodule.c:115:10: fatal error: lzma.h: No such file or directory
#include <lzma.h>
^~~~~~~~
compilation terminated.
error: command ‘/usr/bin/gcc’ failed with exit code 1
—————————————-
ERROR: Command errored out with exit status 1: /usr/bin/python3.9 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’; file=’”’”’/tmp/pip-install-pnrkhuf9/backports-lzma_24feded447a34e5a8b1c53cb80e10341/setup.py’”’”’;f = getattr(tokenize, ‘”’”‘open’”’”’, open)(file) if os.path.exists(file) else io.StringIO(’”’”‘from setuptools import setup; setup()’”’”’);code = f.read().replace(’”’”’\r\n’”’”’, ‘”’”’\n’”’”’);f.close();exec(compile(code, file, ‘”’”‘exec’”’”’))’ install –record /tmp/pip-record-tcqknwy3/install-record.txt –single-version-externally-managed –compile –install-headers /usr/local/python3.9/include/python3.9/backports.lzma Check the logs for full command output.

Solution:

apt install -y liblzma-dev #ubuntu
yum install -y xz-devel    #centos

At this point, there is no problem when executing pip3.9 install backups.lzma

Read More: