我正在使用Python版本3.5.2。
我正在与MSWORD文档中编辑单词和段落。
我需要安装docx
模块。
在命令行中我将其指向路径:
C:UsersdAppDataLocalProgramsPythonPython35-32Scripts
和类型:
pip install python-docx.
击中返回后,我收到此错误消息(下面的完整输出):
"unable to find vcvarsall.bat".
如何解决此错误?
c:UsersDAppDataLocalProgramsPythonPython35-32Scripts>pip install
python-docx
Collecting python-docx
Using cached python-docx-0.8.6.tar.gz
Collecting lxml>=2.3.2 (from python-docx)
Using cached lxml-3.6.4.tar.gz
Installing collected packages: lxml, python-docx
Running setup.py install for lxml ... error
Complete output from command c:usersdappdatalocalprogramspython
python35-32python.exe -u -c "import setuptools, tokenize;__file__='C:\Users\
D\AppData\Local\Temp\pip-build-9yk1nedc\lxml\setup.py';f=getattr(to
kenize, 'open', open)(__file__);code=f.read().replace('rn', 'n');f.close();ex
ec(compile(code, __file__, 'exec'))" install --record C:UsersDAppData
LocalTemppip-pepj9c3f-recordinstall-record.txt --single-version-externally-ma
naged --compile:
Building lxml version 3.6.4.
Building without Cython.
ERROR: b"'xslt-config' is not recognized as an internal or external command,
rnoperable program or batch file.rn"
** 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 buildlib.win32-3.5
creating buildlib.win32-3.5lxml
copying srclxmlbuilder.py -> buildlib.win32-3.5lxml
copying srclxmlcssselect.py -> buildlib.win32-3.5lxml
copying srclxmldoctestcompare.py -> buildlib.win32-3.5lxml
copying srclxmlElementInclude.py -> buildlib.win32-3.5lxml
copying srclxmlpyclasslookup.py -> buildlib.win32-3.5lxml
copying srclxmlsax.py -> buildlib.win32-3.5lxml
copying srclxmlusedoctest.py -> buildlib.win32-3.5lxml
copying srclxml_elementpath.py -> buildlib.win32-3.5lxml
copying srclxml__init__.py -> buildlib.win32-3.5lxml
creating buildlib.win32-3.5lxmlincludes
copying srclxmlincludes__init__.py -> buildlib.win32-3.5lxmlincludes
creating buildlib.win32-3.5lxmlhtml
copying srclxmlhtmlbuilder.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmlclean.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmldefs.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmldiff.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmlElementSoup.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmlformfill.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmlhtml5parser.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmlsoupparser.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtmlusedoctest.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtml_diffcommand.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtml_html5builder.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtml_setmixin.py -> buildlib.win32-3.5lxmlhtml
copying srclxmlhtml__init__.py -> buildlib.win32-3.5lxmlhtml
creating buildlib.win32-3.5lxmlisoschematron
copying srclxmlisoschematron__init__.py -> buildlib.win32-3.5lxmlisosc
hematron
copying srclxmllxml.etree.h -> buildlib.win32-3.5lxml
copying srclxmllxml.etree_api.h -> buildlib.win32-3.5lxml
copying srclxmlincludesc14n.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesconfig.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesdtdvalid.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesetreepublic.pxd -> buildlib.win32-3.5lxmlinclud
es
copying srclxmlincludeshtmlparser.pxd -> buildlib.win32-3.5lxmlinclude
s
copying srclxmlincludesrelaxng.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesschematron.pxd -> buildlib.win32-3.5lxmlinclude
s
copying srclxmlincludestree.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesuri.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesxinclude.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesxmlerror.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesxmlparser.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesxmlschema.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesxpath.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesxslt.pxd -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludesetree_defs.h -> buildlib.win32-3.5lxmlincludes
copying srclxmlincludeslxml-version.h -> buildlib.win32-3.5lxmlinclude
s
creating buildlib.win32-3.5lxmlisoschematronresources
creating buildlib.win32-3.5lxmlisoschematronresourcesrng
copying srclxmlisoschematronresourcesrngiso-schematron.rng -> buildlib
.win32-3.5lxmlisoschematronresourcesrng
creating buildlib.win32-3.5lxmlisoschematronresourcesxsl
copying srclxmlisoschematronresourcesxslRNG2Schtrn.xsl -> buildlib.win
32-3.5lxmlisoschematronresourcesxsl
copying srclxmlisoschematronresourcesxslXSD2Schtrn.xsl -> buildlib.win
32-3.5lxmlisoschematronresourcesxsl
creating buildlib.win32-3.5lxmlisoschematronresourcesxsliso-schematron
-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_abstra
ct_expand.xsl -> buildlib.win32-3.5lxmlisoschematronresourcesxsliso-schema
tron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_dsdl_i
nclude.xsl -> buildlib.win32-3.5lxmlisoschematronresourcesxsliso-schematro
n-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_schema
tron_message.xsl -> buildlib.win32-3.5lxmlisoschematronresourcesxsliso-sch
ematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_schema
tron_skeleton_for_xslt1.xsl -> buildlib.win32-3.5lxmlisoschematronresources
xsliso-schematron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1iso_svrl_f
or_xslt1.xsl -> buildlib.win32-3.5lxmlisoschematronresourcesxsliso-schemat
ron-xslt1
copying srclxmlisoschematronresourcesxsliso-schematron-xslt1readme.txt
-> buildlib.win32-3.5lxmlisoschematronresourcesxsliso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
error: Unable to find vcvarsall.bat
----------------------------------------
Command "c:usersdappdatalocalprogramspythonpython35-32python.exe
-u -c "import setuptools, tokenize;__file__='C:\Users\D\AppData\Local
\Temp\pip-build-9yk1nedc\lxml\setup.py';f=getattr(tokenize, 'open', open)(__
file__);code=f.read().replace('rn', 'n');f.close();exec(compile(code, __file_
_, 'exec'))" install --record C:UsersDAppDataLocalTemppip-pepj9c3f-
recordinstall-record.txt --single-version-externally-managed --compile" failed
with error code 1 in C:UsersDAppDataLocalTemppip-build-9yk1nedclxm
l
这是在Windows上安装LXML Python库的一个众所周知的问题。
TL; DR版本是您从"二进制安装程序包"中安装lxml
的,该软件包已预先编译并为您处理所有详细信息。
您可以在这里找到其中之一:http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
" CP"段代表" C Python"(常规Python,与PYPY相对)和版本,因此,如果您使用Python 2.7,则需要使用名称中的-cp27-
的包装之一。其中有两个,一个用于32位,一个用于64位。您可能需要32位,因为这是Windows上默认的Python安装。
下载二进制安装程序包(" Wheel")后,您可以使用pip
安装它,例如:
pip install lxml‑3.6.4‑cp27‑cp27m‑win32.whl