Python-lxml的构建轮(setup.py)...错误

时间:2020-05-26 06:32:40

标签: python django linux python-3.7

我正在尝试在新服务器上运行一些代码。这不是我的代码,而是100%正常工作,因为它可以在其他一些机器上平稳运行。 当我尝试从需求文件安装必需的模块时,出现以下错误

  ERROR: Command errored out with exit status 1:
   command: /srv/usosapi-env/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-1g1om26q/lxml/setup.py'"'"'; __file__='"'"'/tmp/pip-install-1g1om26q/lxml/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 /tmp/pip-wheel-drhhibz7
       cwd: /tmp/pip-install-1g1om26q/lxml/

查看堆栈跟踪,有:

 x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/libxml2 -Isrc/lxml/includes -I/usr/include/python3.7m -I/srv/usosapi-env/include/python3.7m -c src/lxml/lxml.etree.c -o build/temp.linux-x86_64-3.7/src/lxml/lxml.etree.o -w
  src/lxml/lxml.etree.c: In function ‘__Pyx_ExceptionSave’:
  src/lxml/lxml.etree.c:221049:21: error: ‘PyThreadState’ {aka ‘struct _ts’} has no member named ‘exc_type’; did you mean ‘curexc_type’?

以及其他功能的某些相同错误。

这是我的需求文件:

Django >=1.11, < 2.0
mysqlclient == 1.3.13
cx_Oracle == 5.2.1
lxml == 3.6.2
beautifulsoup4
pylibmc == 1.5.1
django-statsd-mozilla == 0.3.16
statsd == 2.1.2
pillow == 3.2.0
wand >= 0.4.4, <0.5
pycurl >= 7.19.5.1, <7.19.6
PyYAML==5.1.2
tornado == 3.2.2
icalendar == 3.6.2
python-dateutil == 2.5.3
contexttimer == 0.3.1
signxml == 2.5.2
sqlparse == 0.2.1
python-magic == 0.4.12
simplejson==3.10.0
firebase-admin>=2.13
oauth2client==4.1.3
SQLAlchemy==1.2.11
Arpeggio==1.9.0
django-oauth-toolkit==1.1.0
typing
zeep==3.4.0
pyOpenSSL==17.5.0

以及pip在virtualenv中安装的模块:

Package       Version
------------- -------
cx-Oracle     5.2.1
Django        1.11.29
mysqlclient   1.3.13
pip           20.1.1
pkg-resources 0.0.0
pytz          2020.1
setuptools    46.4.0
wheel         0.34.2

我还尝试安装最新的cython(如下所示),但没有结果

Collecting Cython
  Using cached Cython-0.29.19-cp37-cp37m-manylinux1_x86_64.whl (2.0 MB)
Installing collected packages: Cython
Successfully installed Cython-0.29.19

如果有人可以帮助我,我将非常感激

2 个答案:

答案 0 :(得分:0)

检查此自述文件:https://lxml.de/installation.html

我猜测lxml的编译失败,如lxml文档中所述,您可以为平台提供二进制分发,例如python3-lxml。

或设置环境,使其可以使用以下必备条件进行构建: libxml2-dev libxslt-dev python-dev

答案 1 :(得分:0)

问题已解决...

我已将requirements.txt文件更改为不使用指定版本的lxml,并且一切都安装正确。

我想指定的版本对于python 3.7来说太旧了