安装python-lzo失败的pip命令

4

我目前尝试在任何环境中运行pip install python-lzo都失败了(我已经在三台不同的机器上尝试过:ubuntu 16.04,macosx以及基于python:2.7的docker容器):

Collecting python-lzo
  Downloading python-lzo-1.11.tar.gz
Building wheels for collected packages: python-lzo
  Running setup.py bdist_wheel for python-lzo ... error
  Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/2m/0shxv04j04lcm1c0dddyf4qw0000gn/T/pip-build-iOtvF1/python-lzo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/2m/0shxv04j04lcm1c0dddyf4qw0000gn/T/tmp4XTk5Ipip-wheel- --python-tag cp27:
  /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_ext
  building 'lzo' extension
  creating build
  creating build/temp.macosx-10.11-x86_64-2.7
  clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/lzo -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c lzomodule.c -o build/temp.macosx-10.11-x86_64-2.7/lzomodule.o
  lzomodule.c:35:10: fatal error: 'lzo1x.h' file not found
  #include <lzo1x.h>
           ^
  1 error generated.
  error: command 'clang' failed with exit status 1

  ----------------------------------------
  Failed building wheel for python-lzo
  Running setup.py clean for python-lzo
Failed to build python-lzo
Installing collected packages: python-lzo
  Running setup.py install for python-lzo ... error
    Complete output from command /usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/2m/0shxv04j04lcm1c0dddyf4qw0000gn/T/pip-build-iOtvF1/python-lzo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/2m/0shxv04j04lcm1c0dddyf4qw0000gn/T/pip-iXLv5I-record/install-record.txt --single-version-externally-managed --compile:
    /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license'
      warnings.warn(msg)
    running install
    running build
    running build_ext
    building 'lzo' extension
    creating build
    creating build/temp.macosx-10.11-x86_64-2.7
    clang -fno-strict-aliasing -fno-common -dynamic -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/include/lzo -I/usr/local/include -I/usr/local/opt/openssl/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c lzomodule.c -o build/temp.macosx-10.11-x86_64-2.7/lzomodule.o
    lzomodule.c:35:10: fatal error: 'lzo1x.h' file not found
    #include <lzo1x.h>
             ^
    1 error generated.
    error: command 'clang' failed with exit status 1

    ----------------------------------------
Command "/usr/local/opt/python/bin/python2.7 -u -c "import setuptools, tokenize;__file__='/private/var/folders/2m/0shxv04j04lcm1c0dddyf4qw0000gn/T/pip-build-iOtvF1/python-lzo/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/2m/0shxv04j04lcm1c0dddyf4qw0000gn/T/pip-iXLv5I-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/2m/0shxv04j04lcm1c0dddyf4qw0000gn/T/pip-build-iOtvF1/python-lzo/

我正在尝试构建一个运行以下内容的Docker容器:

RUN pip install python-lzo

有什么想法吗?谢谢!
2个回答

3

您需要在Debian基础镜像中安装liblzo2-dev,并在CentOS基础镜像中安装lzo-devel


2
在CentOS上是lzo-devel - Srinivas Reddy Thatiparthy
1
执行 RUN apt-get update && apt-get install -y liblzo2-dev 失败,提示 E: 无法定位软件包 liblzo2-dev - prismofeverything
ubuntu:16.04基础镜像构建Docker容器。 - prismofeverything
这个库只能在Debian或CentOS上工作,而不能在Ubuntu上工作吗? - prismofeverything
根据此URL地址:https://packages.ubuntu.com/xenial/liblzo2-dev 该软件包存在于Ubuntu 16.04中。请查看您的apt仓库以确认是否已添加该软件包。可能是您的仓库存在问题。 - arsalanio
这应该是正确的答案。所选答案太极端了。 - LUser

1
使用以下Dockerfile已解决此问题:
FROM ubuntu:16.04
RUN apt-get update && \
apt-get install -y python python-pip python-lzo zlib1g-dev unzip
RUN pip install bx-python

所以显然你可以直接通过apt安装python-lzo而不是使用pip?叹气

在2023年,只需通过apt-get install -y liblzo2-dev在Ubuntu(18.04)上安装liblzo2-dev即可。因此,我认为这种方法是不必要的。(请参见https://packages.ubuntu.com/bionic/liblzo2-dev) - Regorsmitz

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接