问题描述
我通过此网站和其他网站搜索了解决问题的方法.不幸的是,没有给出的解决方案对我有帮助.
I searched for solution to my problem through this and other sites. Unfortunately, none of given solutions helped me.
我的问题如下.我想安装python lxml库,但是每次出现错误时.
My problem is the following. I'd like to install python lxml library but every time I get errors.
1)当我尝试在pycharm中安装lxml时,出现以下错误:
1) When I try install lxml in pycharm , I get the follwoing error:
ERROR: b"'xslt-config' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n"
2)当我尝试使用pip install lxml在命令行中安装lxml时,出现以下错误:
2) When I try install lxml in command line with pip install lxml, I get the following error:
C:\Windows\system32>pip install lxml
Collecting lxml
Using cached lxml-3.6.0.tar.gz
Installing collected packages: lxml
Running setup.py install for lxml ... error
Complete output from command "c:\program files\python35\python.exe" -u -c "i
mport setuptools, tokenize;__file__='C:\\Users\\forucell\\AppData\\Local\\Temp\\
pip-build-cwlxrbh_\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open)
(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:
\Users\forucell\AppData\Local\Temp\pip-vx4433si-record\install-record.txt --sing
le-version-externally-managed --compile:
Building lxml version 3.6.0.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,
\r\noperable program or batch file.\r\n"
** 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-3.5
creating build\lib.win-amd64-3.5\lxml
copying src\lxml\builder.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\cssselect.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\doctestcompare.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\ElementInclude.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\sax.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\usedoctest.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\_elementpath.py -> build\lib.win-amd64-3.5\lxml
copying src\lxml\__init__.py -> build\lib.win-amd64-3.5\lxml
creating build\lib.win-amd64-3.5\lxml\includes
copying src\lxml\includes\__init__.py -> build\lib.win-amd64-3.5\lxml\includ
es
creating build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\builder.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\clean.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\defs.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\diff.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\formfill.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\html5parser.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\soupparser.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-3.5\lxml\html
copying src\lxml\html\__init__.py -> build\lib.win-amd64-3.5\lxml\html
creating build\lib.win-amd64-3.5\lxml\isoschematron
copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-3.5\lxml\i
soschematron
copying src\lxml\lxml.etree.h -> build\lib.win-amd64-3.5\lxml
copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-3.5\lxml
copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-3.5\lxml\includes
copying src\lxml\includes\config.pxd -> build\lib.win-amd64-3.5\lxml\include
s
copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-3.5\lxml\inclu
des
copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-3.5\lxml\in
cludes
copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-3.5\lxml\inc
ludes
copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-3.5\lxml\includ
es
copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-3.5\lxml\inc
ludes
copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-3.5\lxml\includes
copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-3.5\lxml\includes
copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-3.5\lxml\inclu
des
copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-3.5\lxml\inclu
des
copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-3.5\lxml\incl
udes
copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-3.5\lxml\incl
udes
copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-3.5\lxml\includes
copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-3.5\lxml\includes
copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-3.5\lxml\inclu
des
copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-3.5\lxml\inc
ludes
creating build\lib.win-amd64-3.5\lxml\isoschematron\resources
creating build\lib.win-amd64-3.5\lxml\isoschematron\resources\rng
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib
.win-amd64-3.5\lxml\isoschematron\resources\rng
creating build\lib.win-amd64-3.5\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win
-amd64-3.5\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win
-amd64-3.5\lxml\isoschematron\resources\xsl
creating build\lib.win-amd64-3.5\lxml\isoschematron\resources\xsl\iso-schema
tron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstra
ct_expand.xsl -> build\lib.win-amd64-3.5\lxml\isoschematron\resources\xsl\iso-sc
hematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_i
nclude.xsl -> build\lib.win-amd64-3.5\lxml\isoschematron\resources\xsl\iso-schem
atron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schema
tron_message.xsl -> build\lib.win-amd64-3.5\lxml\isoschematron\resources\xsl\iso
-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schema
tron_skeleton_for_xslt1.xsl -> build\lib.win-amd64-3.5\lxml\isoschematron\resour
ces\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_f
or_xslt1.xsl -> build\lib.win-amd64-3.5\lxml\isoschematron\resources\xsl\iso-sch
ematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt
-> build\lib.win-amd64-3.5\lxml\isoschematron\resources\xsl\iso-schematron-xslt
1
running build_ext
building 'lxml.etree' extension
creating build\temp.win-amd64-3.5
creating build\temp.win-amd64-3.5\Release
creating build\temp.win-amd64-3.5\Release\src
creating build\temp.win-amd64-3.5\Release\src\lxml
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -Isrc\lxml\includes "-Ic:\program files\python35
\include" "-Ic:\program files\python35\include" "-IC:\Program Files (x86)\Micros
oft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Visual St
udio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\1
0.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\
um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Program Fi
les (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows Kits\8
.1\include\\winrt" /Tcsrc\lxml\lxml.etree.c /Fobuild\temp.win-amd64-3.5\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 f
ile: 'libxml/xmlversion.h': No such file or directory
Compile failed: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14
.0\\VC\\BIN\\amd64\\cl.exe' failed with exit status 2
creating Users
creating Users\forucell
creating Users\forucell\AppData
creating Users\forucell\AppData\Local
creating Users\forucell\AppData\Local\Temp
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\amd64\cl.exe /c /
nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/include/libxml2 "-IC:\Program Files (x86)
\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Microsoft Vi
sual Studio 14.0\VC\ATLMFC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\in
clude\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\i
nclude\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\\shared" "-IC:\Pro
gram Files (x86)\Windows Kits\8.1\include\\um" "-IC:\Program Files (x86)\Windows
Kits\8.1\include\\winrt" /TcC:\Users\forucell\AppData\Local\Temp\xmlXPathInit2v
eo73kj.c /FoUsers\forucell\AppData\Local\Temp\xmlXPathInit2veo73kj.obj
xmlXPathInit2veo73kj.c
C:\Users\forucell\AppData\Local\Temp\xmlXPathInit2veo73kj.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 insta
lled?
****************************************************************************
*****
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\B
IN\\amd64\\cl.exe' failed with exit status 2
----------------------------------------
Command ""c:\program files\python35\python.exe" -u -c "import setuptools, tokeni
ze;__file__='C:\\Users\\forucell\\AppData\\Local\\Temp\\pip-build-cwlxrbh_\\lxml
\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replac
e('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\forucell\AppData\
Local\Temp\pip-vx4433si-record\install-record.txt --single-version-externally-ma
naged --compile" failed with error code 1 in C:\Users\forucell\AppData\Local\Tem
p\pip-build-cwlxrbh_\lxml\
3)当我尝试以whl格式安装lxml时,出现以下错误:
3) When I try install lxml in whl format, I get the follwoing error:
Exception:
Traceback (most recent call last):
File "C:\Program Files\Python35\lib\site-packages\pip\basecommand.py", line 21
5, in main
status = self.run(options, args)
File "C:\Program Files\Python35\lib\site-packages\pip\commands\install.py", li
ne 317, in run
prefix=options.prefix_path,
File "C:\Program Files\Python35\lib\site-packages\pip\req\req_set.py", line 74
2, in install
**kwargs
File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", lin
e 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "C:\Program Files\Python35\lib\site-packages\pip\req\req_install.py", lin
e 1032, in move_wheel_files
isolated=self.isolated,
File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 346, in
move_wheel_files
clobber(source, lib_dir, True)
File "C:\Program Files\Python35\lib\site-packages\pip\wheel.py", line 317, in
clobber
ensure_dir(destdir)
File "C:\Program Files\Python35\lib\site-packages\pip\utils\__init__.py", line
83, in ensure_dir
os.makedirs(path)
File "C:\Program Files\Python35\lib\os.py", line 241, in makedirs
mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'C:\\Program Files\\Python35\\Li
b\\site-packages\\lxml
请帮助我.预先感谢.
推荐答案
lxml
需要C/C ++库libxml
,libxstl
,因此您必须首先安装它.但是它们不是Python模块,而是标准库-可能是libxml.dll
,libxstl.dll.
lxml
needs C/C++ libraries libxml
, libxstl
so you have to install it first. But they are not Python modules but standard libraries - probably libxml.dll
, libxstl.dll.
lxml
可能还需要此库或C/C ++头文件* .h的源代码和C/C ++编译器来编译lxml
lxml
may need also source code for this libraries or C/C++ header files *.h and C/C++ compiler to compile lxml
对于Windows,存在具有预编译模块的非官方Windows Python扩展包二进制文件还有lxml
For Windows exists Unofficial Windows Binaries for Python Extension Packages with precompiled modules and there is lxml
这篇关于无法在python 3.5上安装lxml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!