Hublog随手记录一些东西

Linux 安装 Lxml

在 Linux 中使用 pip 安装 lxml 发现如下报错

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
Collecting lxml
  Downloading lxml-4.9.2.tar.gz (3.7 MB)
     |████████████████████████████████| 3.7 MB 44 kB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-evm051b8/lxml_f11746812e61420ca17185b4ddd8f068/setup.py'"'"'; __file__='"'"'/tmp/pip-install-evm051b8/lxml_f11746812e61420ca17185b4ddd8f068/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-f0n190vv
         cwd: /tmp/pip-install-evm051b8/lxml_f11746812e61420ca17185b4ddd8f068/
    Complete output (3 lines):
    Building lxml version 4.9.2.
    Building without Cython.
    Error: Please make sure the libxml2 and libxslt development packages are installed.
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/06/5a/e11cad7b79f2cf3dd2ff8f81fa8ca667e7591d3d8451768589996b65dec1/lxml-4.9.2.tar.gz#sha256=2455cfaeb7ac70338b3257f41e21f0724f4b5b0c0e7702da67ee6c3640835b67 (from https://pypi.org/simple/lxml/) (requires-python:>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, != 3.4.*). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Downloading lxml-4.9.1.tar.gz (3.4 MB)
     |███▉                            | 399 kB 48 kB/s eta 0:01:02^C
ERROR: Operation cancelled by user

根据错误提示可能是缺少了 libxml2 和 libxslt 开发包,执行如下命令安装

apt-get install libxml2 libxml2-dev libxslt1.1 libxslt1-dev

结果还是报错,

根据 lxml 官方安装说明:Installing lxml

执行 apt-get install python3-lxml

安装成功

0%