使用pip安装lxml时出现错误

0 投票
1 回答
733 浏览
提问于 2025-04-18 17:12

我正在尝试在Centos 6上用pip2.7(Python 2.7)安装lxml,但遇到了一个错误。有没有人找到解决办法?我没有像很多人那样使用任何框架,也没有使用其他Java包等。我遇到的问题特别是和Python/pip有关。

 Cleaning up...
    Command /usr/local/bin/python2.7 -c "import setuptools, tokenize;__file__='/tmp/pip_build_user/lxml/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-FHRyQv-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_user/lxml
    Traceback (most recent call last):
      File "/usr/local/bin/pip2.7", line 9, in <module>
        load_entry_point('pip==1.5.6', 'console_scripts', 'pip2.7')()
      File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 185, in main
        return command.main(cmd_args)
      File "/usr/local/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 161, in main
        text = '\n'.join(complete_log)
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 87: ordinal not in range(128)
    [user@user tests]$

1 个回答

0

在这之后,你可以用这个命令来安装一个叫做lxml的库:pip install lxml

yum install libevent-devel python-devel libxslt-devel libxml2-devel

撰写回答