当我使用pip安装lxml时,我发现我没有VC,我google了很多, 但是虽然我为python2.7安装了Visual C ++编译器包,但它没有用。
以下是要点:
以下是错误
C:\Users\deacyn\Desktop>pip install lxml
Collecting lxml
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/4f/3f/cf6daac551fc36cddafa1a71ed48ea5fd642e5feabd3a0d83b8c3dfd0cb4/lxml-3.6.4.tar.gz
Installing collected packages: lxml
Running setup.py install for lxml ... error
Complete output from command "D:\Program Files\python2.7\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\deacyn\\appdata\\local\\temp\\pip-build-vqmbly\\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 c:\users\deacyn\appdata\local\temp\pip-mhhkdn-record\install-record.txt --single-version-externally-managed --compile:
Building lxml version 3.6.4.
Building without Cython.
ERROR: 'xslt-config' 不是内部或外部命令,也不是可运行的程序
或批处理文件。(Is not an internal or external command, nor a running program or batch file.)
** make sure the development packages of libxml2 and libxslt are installed **
Using build configuration of libxslt
running install
running build
running build_py
creating build
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\lxml
copying src\lxml\builder.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\cssselect.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\doctestcompare.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\ElementInclude.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\sax.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\usedoctest.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\_elementpath.py -> build\lib.win-amd64-2.7\lxml
copying src\lxml\__init__.py -> build\lib.win-amd64-2.7\lxml
creating build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\__init__.py -> build\lib.win-amd64-2.7\lxml\includes
creating build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\builder.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\clean.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\defs.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\diff.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\formfill.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\html5parser.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\soupparser.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-2.7\lxml\html
copying src\lxml\html\__init__.py -> build\lib.win-amd64-2.7\lxml\html
creating build\lib.win-amd64-2.7\lxml\isoschematron
copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-2.7\lxml\isoschematron
copying src\lxml\lxml.etree.h -> build\lib.win-amd64-2.7\lxml
copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-2.7\lxml
copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\config.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-2.7\lxml\includes
copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-2.7\lxml\includes
creating build\lib.win-amd64-2.7\lxml\isoschematron\resources
creating build\lib.win-amd64-2.7\lxml\isoschematron\resources\rng
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\rng
creating build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl
creating build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-2.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
creating build\temp.win-amd64-2.7\Release\src
creating build\temp.win-amd64-2.7\Release\src\lxml
C:\Users\deacyn\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Isrc\lxml\includes "-ID:\Program Files\python2.7\include" "-ID:\Program Files\python2.7\PC" /Tcsrc\lxml\lxml.etree.c /Fobuild\temp.win-amd64-2.7\Release\src\lxml\lxml.etree.obj -w
cl : Command line warning D9025 : overriding '/W3' with '/w'
lxml.etree.c
src\lxml\includes\etree_defs.h(14) : fatal error C1083: Cannot open include file: 'libxml/xmlversion.h': No such file or directory
Compile failed: command 'C:\\Users\\deacyn\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2
creating users
creating users\deacyn
creating users\deacyn\appdata
creating users\deacyn\appdata\local
creating users\deacyn\appdata\local\temp
C:\Users\deacyn\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I/usr/include/libxml2 /Tcc:\users\deacyn\appdata\local\temp\xmlXPathInitdwvu3g.c /Fousers\deacyn\appdata\local\temp\xmlXPathInitdwvu3g.obj
xmlXPathInitdwvu3g.c
c:\users\deacyn\appdata\local\temp\xmlXPathInitdwvu3g.c(1) : fatal error C1083: Cannot open include file: 'libxml/xpath.h': No such file or directory
*********************************************************************************
Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed?
*********************************************************************************
error: command
'C:\\Users\\deacyn\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2
----------------------------------------
Command ""D:\Program Files\python2.7\python.exe" -u -c "import setuptools, tokenize;__file__='c:\\users\\deacyn\\appdata\\local\\temp\\pip-build-vqmbly\\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 c:\users\deacyn\appdata\local\temp\pip-mhhkdn-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\deacyn\appdata\local\temp\pip-build-vqmbly\lxml\
答案 0 :(得分:1)
您是否检查过:无法在库libxml2中找到函数xmlCheckVersion。是否安装了libxml2?
问题是由版本引起的.Python版本是2.7,而我最初下载的lxml是3.6。当我下载lxml 2.2.8.exe时,我惊喜地发现问题已经解决了。