2016-11-20 102 views
2

我在安裝python 3模塊時遇到了一些問題。我試圖使用PIP安裝Python的docx:Python錯誤:命令'C:\ Program Files(x86)\ Microsoft Visual Studio 14.0 \ VC \ BIN \ cl.exe'以退出狀態失敗4

PIP安裝python-DOCX

爲Python 3.4和以下是錯誤我得到:

error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 4 

以下是完整的消息:

*C:\Python34>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:\users\sultan ahmed\appdata\local\programs\python\python35-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\SULTAN~1\\AppData\\Local\\Temp\\pip-build-9px1syzb\\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\SULTAN~1\AppData\Local\Temp\pip-ea3o7pxk-record\install-record.txt --single-version-externally-managed --compile: 
    Building lxml version 3.6.4. 
    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\isoschematron 
    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\includes 
    copying src\lxml\includes\htmlparser.pxd -> build\lib.win32-3.5\lxml\includes 
    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\includes 
    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\includes 
    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.win32-3.5\lxml\isoschematron\resources\xsl 
    copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win32-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_abstract_expand.xsl -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
    copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
    copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-schematron-xslt1 
    copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_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_for_xslt1.xsl -> build\lib.win32-3.5\lxml\isoschematron\resources\xsl\iso-schematron-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 
    creating build\temp.win32-3.5 
    creating build\temp.win32-3.5\Release 
    creating build\temp.win32-3.5\Release\src 
    creating build\temp.win32-3.5\Release\src\lxml 
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Isrc\lxml\includes "-Ic:\users\sultan ahmed\appdata\local\programs\python\python35-32\include" "-Ic:\users\sultan ahmed\appdata\local\programs\python\python35-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Microsoft Visual Studio\VC98\atl\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\VC98\mfc\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\VC98\include" /Tcsrc\lxml\lxml.etree.c /Fobuild\temp.win32-3.5\Release\src\lxml\lxml.etree.obj -w 
    fatal error C1510: Cannot load language resource clui.dll. 
    Compile failed: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 4 
    creating Users 
    creating Users\SULTAN~1 
    creating Users\SULTAN~1\AppData 
    creating Users\SULTAN~1\AppData\Local 
    creating Users\SULTAN~1\AppData\Local\Temp 
    C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -I/usr/include/libxml2 "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Microsoft Visual Studio\VC98\atl\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\VC98\mfc\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\VC98\include" /TcC:\Users\SULTAN~1\AppData\Local\Temp\xmlXPathInitjiyz_drd.c /FoUsers\SULTAN~1\AppData\Local\Temp\xmlXPathInitjiyz_drd.obj 
    fatal error C1510: Cannot load language resource clui.dll. 
    ********************************************************************************* 
    Could not find function xmlCheckVersion in library libxml2. Is libxml2 installed? 
    ********************************************************************************* 
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 4 

    ---------------------------------------- 
Command ""c:\users\sultan ahmed\appdata\local\programs\python\python35-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\SULTAN~1\\AppData\\Local\\Temp\\pip-build-9px1syzb\\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\SULTAN~1\AppData\Local\Temp\pip-ea3o7pxk-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\SULTAN~1\AppData\Local\Temp\pip-build-9px1syzb\lxml\* 

我之前有過模塊安裝的其他問題,我通過安裝Visual Studio C++ 2010解決了這些問題

順便說一句,其他模塊的安裝工作得很好。

我的規格:10的Windows 64

的Python 3.4

回答

3

解決這個問題的最快方法是從一個二進制安裝程序安裝lxml

http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

它看起來像Visual Studio的C編譯器無法找到libxml2和/或libxslt C庫,這是防止lxml無法安裝,因爲它依賴於這兩個常見的問題。

如果你真的想從源代碼構建它,那麼這就是你接下來要追求的方向,確認這兩個C庫的安裝。但大多數人只需從二進制文件安裝lxml

+1

我有同樣的問題(除「退出狀態2」,而不是4),這對我來說工作得很快。謝謝。注意其他人:確保你得到符合你的python bit版本(32或64)的lxml輪子,否則你會得到一個錯誤,說明該輪子在該平臺上不受支持。 –

+0

@ J.Saw我聽說Windows上的默認Python安裝是32位,即使在64位Windows上也是如此。所以,這使得你的建議更重要:)我相信在Python命令提示符處執行這一小段代碼可以可靠地告訴你你已經安裝了哪些東西:import struct; print struct.calcsize(「P」)* 8' ,打印32或64取決於。 – scanny

相關問題