如何在 Amazon Linux 上使用 python3.7 安装 lxml<4.0 2
How to install lxml<4.0 with python3.7 on Amazon Linux 2
我正在尝试在亚马逊 Linux 2 图像上安装 lxml<4.0
python 3.7
sudo pip3 install "lxml<4.0"
首先它尝试构建轮子:
... truncated output ...
src/lxml/lxml.etree.c: In function ‘__Pyx_PyList_Pop’:
src/lxml/lxml.etree.c:4532:83: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))__pyx_umethod_PyList_Type_pop.func’
(PY_VERSION_HEX >= 0x030600B1 && (cfunc)->flag == METH_FASTCALL ? (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL) :\
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lxml/lxml.etree.c:234476:12: note: in expansion of macro ‘__Pyx_CallUnboundCMethod0’
return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
^
src/lxml/lxml.etree.c: In function ‘__Pyx_PyDict_Values’:
src/lxml/lxml.etree.c:4532:83: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))__pyx_umethod_PyDict_Type_values.func’
(PY_VERSION_HEX >= 0x030600B1 && (cfunc)->flag == METH_FASTCALL ? (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL) :\
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lxml/lxml.etree.c:235119:16: note: in expansion of macro ‘__Pyx_CallUnboundCMethod0’
return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_values, d);
^
Compile failed: command 'gcc' failed with exit status 1
creating tmp
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitnqtfzdpm.c -o tmp/xmlXPathInitnqtfzdpm.o
/tmp/xmlXPathInitnqtfzdpm.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main (int argc, char **argv) {
^~~~
cc tmp/xmlXPathInitnqtfzdpm.o -L/usr/lib64 -lxml2 -o a.out
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for lxml
然后尝试 setup.py
:
... truncated output ...
src/lxml/lxml.etree.c: In function ‘__Pyx_PyDict_Values’:
src/lxml/lxml.etree.c:4532:83: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))__pyx_umethod_PyDict_Type_values.func’
(PY_VERSION_HEX >= 0x030600B1 && (cfunc)->flag == METH_FASTCALL ? (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL) :\
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lxml/lxml.etree.c:235119:16: note: in expansion of macro ‘__Pyx_CallUnboundCMethod0’
return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_values, d);
^
Compile failed: command 'gcc' failed with exit status 1
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInit72g06utf.c -o tmp/xmlXPathInit72g06utf.o
/tmp/xmlXPathInit72g06utf.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main (int argc, char **argv) {
^~~~
cc tmp/xmlXPathInit72g06utf.o -L/usr/lib64 -lxml2 -o a.out
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1qjhur44/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jqitj_hs-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-1qjhur44/lxml/
好像不是缺少库的问题,而是不兼容的问题。我该如何解决这个问题?
看起来 lxml<4.0 只是不支持 python 3.7。关于这些坏消息我很遗憾。 https://pypi.org/project/lxml/3.8.0/ (the latest <4.0 version) only says it supports up to python 3.6; https://github.com/hynek/doc2dash/issues/93#issuecomment-441318128 确认。
啊哈,来自 https://pypi.org/project/lxml/4.0.0/#bugs-fixed :
Compilation under Py3.7-pre failed due to a modified function signature.
我正在尝试在亚马逊 Linux 2 图像上安装 lxml<4.0
python 3.7
sudo pip3 install "lxml<4.0"
首先它尝试构建轮子:
... truncated output ...
src/lxml/lxml.etree.c: In function ‘__Pyx_PyList_Pop’:
src/lxml/lxml.etree.c:4532:83: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))__pyx_umethod_PyList_Type_pop.func’
(PY_VERSION_HEX >= 0x030600B1 && (cfunc)->flag == METH_FASTCALL ? (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL) :\
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lxml/lxml.etree.c:234476:12: note: in expansion of macro ‘__Pyx_CallUnboundCMethod0’
return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyList_Type_pop, L);
^
src/lxml/lxml.etree.c: In function ‘__Pyx_PyDict_Values’:
src/lxml/lxml.etree.c:4532:83: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))__pyx_umethod_PyDict_Type_values.func’
(PY_VERSION_HEX >= 0x030600B1 && (cfunc)->flag == METH_FASTCALL ? (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL) :\
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lxml/lxml.etree.c:235119:16: note: in expansion of macro ‘__Pyx_CallUnboundCMethod0’
return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_values, d);
^
Compile failed: command 'gcc' failed with exit status 1
creating tmp
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInitnqtfzdpm.c -o tmp/xmlXPathInitnqtfzdpm.o
/tmp/xmlXPathInitnqtfzdpm.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main (int argc, char **argv) {
^~~~
cc tmp/xmlXPathInitnqtfzdpm.o -L/usr/lib64 -lxml2 -o a.out
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for lxml
然后尝试 setup.py
:
... truncated output ...
src/lxml/lxml.etree.c: In function ‘__Pyx_PyDict_Values’:
src/lxml/lxml.etree.c:4532:83: error: too many arguments to function ‘(PyObject * (*)(PyObject *, PyObject * const*, Py_ssize_t))__pyx_umethod_PyDict_Type_values.func’
(PY_VERSION_HEX >= 0x030600B1 && (cfunc)->flag == METH_FASTCALL ? (*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &PyTuple_GET_ITEM(__pyx_empty_tuple, 0), 0, NULL) :\
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/lxml/lxml.etree.c:235119:16: note: in expansion of macro ‘__Pyx_CallUnboundCMethod0’
return __Pyx_CallUnboundCMethod0(&__pyx_umethod_PyDict_Type_values, d);
^
Compile failed: command 'gcc' failed with exit status 1
cc -I/usr/include/libxml2 -I/usr/include/libxml2 -c /tmp/xmlXPathInit72g06utf.c -o tmp/xmlXPathInit72g06utf.o
/tmp/xmlXPathInit72g06utf.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
main (int argc, char **argv) {
^~~~
cc tmp/xmlXPathInit72g06utf.o -L/usr/lib64 -lxml2 -o a.out
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-1qjhur44/lxml/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-jqitj_hs-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-1qjhur44/lxml/
好像不是缺少库的问题,而是不兼容的问题。我该如何解决这个问题?
看起来 lxml<4.0 只是不支持 python 3.7。关于这些坏消息我很遗憾。 https://pypi.org/project/lxml/3.8.0/ (the latest <4.0 version) only says it supports up to python 3.6; https://github.com/hynek/doc2dash/issues/93#issuecomment-441318128 确认。
啊哈,来自 https://pypi.org/project/lxml/4.0.0/#bugs-fixed :
Compilation under Py3.7-pre failed due to a modified function signature.