Skip to main content
 首页 » 编程设计

python之如何在 .virtualenvs 上安装 libxml2-python-2.6.9.tar.gz

2025年05月04日11lyhabc

在 virtualenvs 中安装 libxml2 时出现以下错误:

Fatal error: local() encountered an error (return code 1) while executing 'pip install ftp://xmlsoft.org/libxml2/python/libxml2-python-2.6.9.tar.gz' 

关于错误信息的更多信息:

 Downloading libxml2-python-2.6.9.tar.gz (201kB): 201kB downloaded 
  Running setup.py egg_info for package from ftp://xmlsoft.org/libxml2/python/libxml2-python-2.6.9.tar.gz 
    /usr/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license' 
      warnings.warn(msg) 
    Found 1466 functions in libxml2-api.xml 
    Found 51 functions in libxml2-python-api.xml 
    Generated 824 wrapper functions, 489 failed, 204 skipped 
 
    Missing type converters: 
    xmlInputMatchCallback:1  xmlXPathFuncLookupFunc:1  xmlNotationTablePtr:2  xmlXPathObjectPtr:22  xmlLocationSetPtr:6  xmlEnumerationPtr:5  xmlElementTablePtr:2  const htmlEntityDesc *:2  xmlChar **:15  xmlXPathCompExprPtr:5  xmlDocPtr *:1  xmlTextReaderErrorFunc:1  xmlOutputMatchCallback:1  xmlExternalEntityLoader:2  xmlRelaxNGValidityErrorFunc *:2  xmlPatternPtr:3  xmlEntitiesTablePtr:3  xmlStructuredErrorFunc:1  xmlNsPtr *:1  xmlBufferAllocationScheme:3  xmlEnumerationPtr *:2  const xmlParserNodeInfo *:1  xmlXPathVariableLookupFunc:1  xmlShellCtxtPtr:10  xlinkNodeDetectFunc:2  xmlSchemaTypePtr:5  xmlRefTablePtr:1  xmlParserNodeInfoPtr:1  xmlAttributeTablePtr:2  xmlCharEncodingHandler *:4  xmlXIncludeCtxtPtr:4  xmlRelaxNGValidityErrorFunc:2  xmlParserNodeInfoSeqPtr:3  xmlSchemaFacetPtr:3  xmlTextReaderErrorFunc *:1  xmlOutputWriteCallback:2  xlinkHandlerPtr:2  xmlSchemaParserCtxtPtr:6  xmlValidCtxtPtr:25  xmlRegExecCallbacks:1  size_t:1  xmlDeregisterNodeFunc:2  xmlChRangeGroupPtr:1  va_list:1  xmlSAXHandler *:4  xmlSchemaValPtr:2  ...:1  xmlShellReadlineFunc:1  xmlDict *:1  htmlElemDesc *:3  xmlCharEncodingHandlerPtr:7  xmlNodePtr *:1  xmlCharEncodingInputFunc:1  xmlAutomataPtr:16  xmlEntityReferenceFunc:1  xmlInputReadCallback:7  xmlC14NIsVisibleCallback:1  xmlAttributeType:1  char **:5  xmlXPathFunction:4  xmlCharEncoding:12  xmlNodeSetPtr:32  xmlParserInputPtr:17  htmlStatus:1  xmlSchemaPtr:3  xmlRegisterNodeFunc:2  xmlIDTablePtr:1  xmlRegExecCtxtPtr:3  xmlElementContentPtr *:1  xmlCatalogAllow:2  xmlElementContentType:1  xmlElementContent *:1  xmlDictPtr:8  void *:89  xmlTextWriterPtr:77  xmlSchemaValidCtxtPtr:4  xmlCatalogPrefer:1  xmlElementContentPtr:6  xmlNotationPtr:1  const htmlElemDesc *:1  xlinkType:1  xmlGenericErrorFunc *:1  xmlSaveCtxtPtr:6 
    Found 214 functions in libxslt-api.xml 
    Found 27 functions in libxslt-python-api.xml 
    Generated 125 wrapper functions, 83 failed, 33 skipped 
 
    Missing type converters: 
    xsltTopLevelFunction:2  xsltDecimalFormatPtr:2  xmlChar **:2  xmlXPathCompExprPtr:4  xsltPreComputeFunction:1  xsltElemPreCompPtr:2  xsltDebugTraceCodes:2  xsltSecurityPrefsPtr:11  xsltSortFunc:2  xsltTemplatePtr:4  pythonObject *:4  ...:1  xsltNumberDataPtr:1  xmlNodePtr *:3  xsltExtInitFunction:2  char **:2  xmlXPathObjectPtr *:1  xmlNodeSetPtr:2  xmlXPathFunction:4  xsltTransformFunction:5  xsltCompMatchPtr:3  void *:10  xmlOutputBufferPtr:1  xmlHashTablePtr:1  xmlDictPtr:1  xsltDocumentPtr:7  xsltStackElemPtr:3 
 
Installing collected packages: libxml2-python 
  Running setup.py install for libxml2-python 
    /usr/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license' 
      warnings.warn(msg) 
    building 'libxml2mod' extension 
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT=1 -DMERGED_MODULES=1 -I/usr/include/libxml2 -I/usr/include -I/usr/include/libxslt -I/usr/include/python2.7 -c libxml2-py.c -o build/temp.linux-x86_64-2.7/libxml2-py.o 
    libxml2-py.c: In function ‘libxml_xmlUTF8Strpos’: 
    libxml2-py.c:11913:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default] 
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT=1 -DMERGED_MODULES=1 -I/usr/include/libxml2 -I/usr/include -I/usr/include/libxslt -I/usr/include/python2.7 -c libxml.c -o build/temp.linux-x86_64-2.7/libxml.o 
    libxml.c: In function ‘pythonStartElement’: 
    libxml.c:624:13: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
    libxml.c:636:21: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
    libxml.c: In function ‘libxml_xmlParserCtxtGetErrorHandler’: 
    libxml.c:1562:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
    libxml.c:1564:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
    libxml.c: In function ‘libxml_xmlTextReaderGetErrorHandler’: 
    libxml.c:1716:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
    libxml.c:1718:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
    libxml.c: In function ‘libxml_serializeNode’: 
    libxml.c:2466:28: error: dereferencing pointer to incomplete type 
    libxml.c:2467:33: error: dereferencing pointer to incomplete type 
    libxml.c:2468:22: error: dereferencing pointer to incomplete type 
    libxml.c:2470:30: error: dereferencing pointer to incomplete type 
    libxml.c:2471:35: error: dereferencing pointer to incomplete type 
    libxml.c:2472:24: error: dereferencing pointer to incomplete type 
    libxml.c:2501:32: error: dereferencing pointer to incomplete type 
    libxml.c:2502:37: error: dereferencing pointer to incomplete type 
    libxml.c:2503:26: error: dereferencing pointer to incomplete type 
    libxml.c:2505:34: error: dereferencing pointer to incomplete type 
    libxml.c:2506:39: error: dereferencing pointer to incomplete type 
    libxml.c:2507:28: error: dereferencing pointer to incomplete type 
    libxml.c:2542:32: error: dereferencing pointer to incomplete type 
    libxml.c:2543:37: error: dereferencing pointer to incomplete type 
    libxml.c:2544:26: error: dereferencing pointer to incomplete type 
    libxml.c:2546:34: error: dereferencing pointer to incomplete type 
    libxml.c:2547:39: error: dereferencing pointer to incomplete type 
    libxml.c:2548:28: error: dereferencing pointer to incomplete type 
    libxml.c: In function ‘initlibxml2mod’: 
    libxml.c:3213:15: warning: variable ‘m’ set but not used [-Wunused-but-set-variable] 
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 
    Complete output from command /home/marko/.virtualenvs/jb-backend/bin/python -c "import setuptools;__file__='/tmp/pip-pW8UbM-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TJ_Dac-record/install-record.txt --single-version-externally-managed --install-headers /home/marko/.virtualenvs/jb-backend/include/site/python2.7: 
    /usr/lib/python2.7/distutils/dist.py:251: UserWarning: 'licence' distribution option is deprecated; use 'license' 
 
  warnings.warn(msg) 
 
running install 
 
running build 
 
running build_py 
 
creating build 
 
creating build/lib.linux-x86_64-2.7 
 
copying libxml2.py -> build/lib.linux-x86_64-2.7 
 
copying drv_libxml2.py -> build/lib.linux-x86_64-2.7 
 
copying libxslt.py -> build/lib.linux-x86_64-2.7 
 
running build_ext 
 
building 'libxml2mod' extension 
 
creating build/temp.linux-x86_64-2.7 
 
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT=1 -DMERGED_MODULES=1 -I/usr/include/libxml2 -I/usr/include -I/usr/include/libxslt -I/usr/include/python2.7 -c libxml2-py.c -o build/temp.linux-x86_64-2.7/libxml2-py.o 
 
libxml2-py.c: In function ‘libxml_xmlUTF8Strpos’: 
 
libxml2-py.c:11913:14: warning: assignment discards ‘const’ qualifier from pointer target type [enabled by default] 
 
x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -D_REENTRANT=1 -DMERGED_MODULES=1 -I/usr/include/libxml2 -I/usr/include -I/usr/include/libxslt -I/usr/include/python2.7 -c libxml.c -o build/temp.linux-x86_64-2.7/libxml.o 
 
libxml.c: In function ‘pythonStartElement’: 
 
libxml.c:624:13: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
 
libxml.c:636:21: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
 
libxml.c: In function ‘libxml_xmlParserCtxtGetErrorHandler’: 
 
libxml.c:1562:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
 
libxml.c:1564:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
 
libxml.c: In function ‘libxml_xmlTextReaderGetErrorHandler’: 
 
libxml.c:1716:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
 
libxml.c:1718:2: warning: the comparison will always evaluate as ‘false’ for the address of ‘_Py_NoneStruct’ will never be NULL [-Waddress] 
 
libxml.c: In function ‘libxml_serializeNode’: 
 
libxml.c:2466:28: error: dereferencing pointer to incomplete type 
 
libxml.c:2467:33: error: dereferencing pointer to incomplete type 
 
libxml.c:2468:22: error: dereferencing pointer to incomplete type 
 
libxml.c:2470:30: error: dereferencing pointer to incomplete type 
 
libxml.c:2471:35: error: dereferencing pointer to incomplete type 
 
libxml.c:2472:24: error: dereferencing pointer to incomplete type 
 
libxml.c:2501:32: error: dereferencing pointer to incomplete type 
 
libxml.c:2502:37: error: dereferencing pointer to incomplete type 
 
libxml.c:2503:26: error: dereferencing pointer to incomplete type 
 
libxml.c:2505:34: error: dereferencing pointer to incomplete type 
 
libxml.c:2506:39: error: dereferencing pointer to incomplete type 
 
libxml.c:2507:28: error: dereferencing pointer to incomplete type 
 
libxml.c:2542:32: error: dereferencing pointer to incomplete type 
 
libxml.c:2543:37: error: dereferencing pointer to incomplete type 
 
libxml.c:2544:26: error: dereferencing pointer to incomplete type 
 
libxml.c:2546:34: error: dereferencing pointer to incomplete type 
 
libxml.c:2547:39: error: dereferencing pointer to incomplete type 
 
libxml.c:2548:28: error: dereferencing pointer to incomplete type 
 
libxml.c: In function ‘initlibxml2mod’: 
 
libxml.c:3213:15: warning: variable ‘m’ set but not used [-Wunused-but-set-variable] 
 
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 
 
---------------------------------------- 
Command /home/marko/.virtualenvs/jb-backend/bin/python -c "import setuptools;__file__='/tmp/pip-pW8UbM-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-TJ_Dac-record/install-record.txt --single-version-externally-managed --install-headers /home/marko/.virtualenvs/jb-backend/include/site/python2.7 failed with error code 1 in /tmp/pip-pW8UbM-build 
Storing complete log in /home/marko/.pip/pip.log 
 
Fatal error: local() encountered an error (return code 1) while executing 'pip install ftp://xmlsoft.org/libxml2/python/libxml2-python-2.6.9.tar.gz' 

有什么想法吗? 非常感谢

请您参考如下方法:

试试这个解决方案:https://pkimber.net/howto/python/pip/install-modules.html

激活你的python虚拟环境...

构建和安装:

$ wget ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz 
$ tar xf libxml2-2.9.1.tar.gz 
$ cd libxml2-2.9.1 
$ ./configure 
$ make 
$ cd python 
(virtenv)$ python setup.py install