在Windows上安装python-docx

时间:2016-06-22 13:09:14

标签: python libxml2 python-docx libxslt

当我尝试在我的机器上安装python-docx时,我会收到其他问题中没有看到的错误...这里是命令提示符代码 -

C:\windows\system32>pip install python-docx
Collecting python-docx
  Using cached python-docx-0.8.5.tar.gz
Collecting lxml>=2.3.2 (from python-docx)
  Using cached lxml-3.6.0.tar.gz
Installing collected packages: lxml, python-docx
  Running setup.py install for lxml ... error
    Complete output from command "c:\program files (x86)\python35-32\python.exe"
 -u -c "import setuptools, tokenize;__file__='C:\\Users\\usr\\AppData\\Local
\\Temp\\pip-build-zk13t9st\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open
', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --r
ecord C:\Users\usr\AppData\Local\Temp\pip-auod13yy-record\install-record.txt
 --single-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.win32-3.5
creating build\lib.win32-3.5\lxml
copying src\lxml\builder.py -> build\lib.win32-3.5\lxml
copying src\lxml\cssselect.py -> build\lib.win32-3.5\lxml
copying src\lxml\doctestcompare.py -> build\lib.win32-3.5\lxml
copying src\lxml\ElementInclude.py -> build\lib.win32-3.5\lxml
copying src\lxml\pyclasslookup.py -> build\lib.win32-3.5\lxml
copying src\lxml\sax.py -> build\lib.win32-3.5\lxml
copying src\lxml\usedoctest.py -> build\lib.win32-3.5\lxml
copying src\lxml\_elementpath.py -> build\lib.win32-3.5\lxml
copying src\lxml\__init__.py -> build\lib.win32-3.5\lxml
creating build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\__init__.py -> build\lib.win32-3.5\lxml\includes
    creating build\lib.win32-3.5\lxml\html
copying src\lxml\html\builder.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\clean.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\defs.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\diff.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\ElementSoup.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\formfill.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\html5parser.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\soupparser.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\usedoctest.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\_diffcommand.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\_html5builder.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\_setmixin.py -> build\lib.win32-3.5\lxml\html
copying src\lxml\html\__init__.py -> build\lib.win32-3.5\lxml\html
creating build\lib.win32-3.5\lxml\isoschematron
copying src\lxml\isoschematron\__init__.py -> build\lib.win32-3.5\lxml\isosc
hematron
copying src\lxml\lxml.etree.h -> build\lib.win32-3.5\lxml
copying src\lxml\lxml.etree_api.h -> build\lib.win32-3.5\lxml
copying src\lxml\includes\c14n.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\config.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\dtdvalid.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\etreepublic.pxd -> build\lib.win32-3.5\lxml\includ
es
copying src\lxml\includes\htmlparser.pxd -> build\lib.win32-3.5\lxml\include
s
copying src\lxml\includes\relaxng.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\schematron.pxd -> build\lib.win32-3.5\lxml\include
s
copying src\lxml\includes\tree.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\uri.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\xinclude.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\xmlerror.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\xmlparser.pxd -> build\lib.win32-3.5\lxml\includes

copying src\lxml\includes\xmlschema.pxd -> build\lib.win32-3.5\lxml\includes

copying src\lxml\includes\xpath.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\xslt.pxd -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\etree_defs.h -> build\lib.win32-3.5\lxml\includes
copying src\lxml\includes\lxml-version.h -> build\lib.win32-3.5\lxml\include
s
creating build\lib.win32-3.5\lxml\isoschematron\resources
creating build\lib.win32-3.5\lxml\isoschematron\resources\rng
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib
.win32-3.5\lxml\isoschematron\resources\rng
creating build\lib.win32-3.5\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win
32-3.5\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win
32-3.5\lxml\isoschematron\resources\xsl
creating build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-schematron
-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstra
ct_expand.xsl -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-        schema
tron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_i
nclude.xsl -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-    schematro
n-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schema
tron_message.xsl -> build\lib.win32-    3.5\lxml\isoschematron\resources\xsl\iso-sch
ematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schema
tron_skeleton_for_xslt1.xsl -> build\lib.win32-  3.5\lxml\isoschematron\resources\
xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_f
or_xslt1.xsl -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-   schemat
ron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt
 -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
error: Unable to find vcvarsall.bat

----------------------------------------
Command ""c:\program files (x86)\python35-32\python.exe" -u -c "import setuptool
s, tokenize;__file__='C:\\Users\\usr\\AppData\\Local\\Temp\\pip-build-  zk13t9
st\\lxml\\setup.py';exec(compile(getattr(tokenize, 'open', open) (__file__).read(
).replace('\r\n', '\n'), __file__, 'exec'))" install --record    C:\Users\usr\A
ppData\Local\Temp\pip-auod13yy-record\install-record.txt --single-version-extern
ally-managed --compile" failed with error code 1 in    C:\Users\usr\AppData\Loc
al\Temp\pip-build-zk13t9st\lxml\

*用' usr'覆盖了我的用户名。 ' xslt-config'的错误是什么?没被认出来?我也搜过了这个,但我没试过。我也试过安装libxml2和libxslt,但是它们都没有工作(在pypi上没有识别?)。关于没有找到' vcvarsall.bat'的错误也令人困惑。然后它继续说"编译失败,错误代码1"。有谁知道电脑试图告诉我什么?我已多次尝试阅读此代码,但无法找到解决方案。任何帮助表示赞赏。提前谢谢!

1 个答案:

答案 0 :(得分:0)

libxml2和libxslt是lxml依赖的C代码库。您可以尝试从二进制发行版安装lxml,看看是否能让您超越它。