Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Building wheel for lxml (setup.py) ... error

I'm trying to run some code on my new server. It's not my code, but it's 100% working, because it runs smoothly on some other machines. When I try to install required modules from requirements file, I'm getting following error

  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/

Looking down into stacktrace, there is:

 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’?

And some identical errors for other functions.

Here's my requirements file:

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

And modules installed in virtualenv by pip:

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

I also tried to install newest cython (as follows), but no results

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

If anybody could help me, I'd be very grateful

like image 976
macko Avatar asked Jul 25 '26 06:07

macko


2 Answers

Problem resolved...

I've changed requirements.txt file to not using specified version of lxml, and everything installed fine.

I guess that specified version was too old for python 3.7

like image 103
macko Avatar answered Jul 26 '26 18:07

macko


Check this readme: https://lxml.de/installation.html

I'm guessing compilation of lxml fails, as described in lxml docs, you can either provide binary distribution for your platform for instance python3-lxml.

Or setup environment to make it possible to build with these prequisites: libxml2-dev libxslt-dev python-dev

like image 22
Michał K Avatar answered Jul 26 '26 20:07

Michał K