2016-11-06 55 views
1

为Python 3.5安装LXML,libxml2的,的libxslt我第一次尝试运行基本PIP install命令吧:在Windows 10

C:\Program Files (x86)\Python35-32>pip install lxml 
Collecting lxml 
    Using cached lxml-3.6.4.tar.gz 
Building wheels for collected packages: lxml 
    Running setup.py bdist_wheel for lxml ... error 
    Complete output from command "c:\program files (x86)\python35-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\Djidiouf\\AppData\\Local\\Temp\\pip-build-ovqa6ncd\\lxml\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\Djidiouf\AppData\Local\Temp\tmp9hzx5gztpip-wheel- --python-tag cp35: 
    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 ** 


    C:\Users\Djidiouf\AppData\Local\Temp\xmlXPathInitbqgvj3pt.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:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\cl.exe' failed with exit status 2 

    ---------------------------------------- 
Command ""c:\program files (x86)\python35-32\python.exe" -u -c "import setuptools, tokenize;__file__='C:\\Users\\Djidiouf\\AppData\\Local\\Temp\\pip-build-ovqa6ncd\\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\Djidiouf\AppData\Local\Temp\pip-kk7fdpzx-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\Djidiouf\AppData\Local\Temp\pip-build-ovqa6ncd\lxml\ 

我试图安装的libxml2:

C:\Program Files (x86)\Python35-32>pip install libxml2 
Collecting libxml2 
    Could not find a version that satisfies the requirement libxml2 (from versions:) 
No matching distribution found for libxml2 

我还试图安装的libxslt:

C:\Program Files (x86)\Python35-32>pip install libxslt 
Collecting libxslt 
    Could not find a version that satisfies the requirement libxslt (from versions:) 
No matching distribution found for libxslt 

我还试图建立从源(https://github.com/lxml/lxml)LXML但它需要了libx ml2依赖关系。

我试图从http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml下载LXML文件后车轮以及安装它:

C:\Program Files (x86)\Python35-32>pip install C:\Users\Djidiouf\Downloads\lxml-3.6.4-cp35-cp35m-win_amd64.whl 
lxml-3.6.4-cp35-cp35m-win_amd64.whl is not a supported wheel on this platform. 

看来,这轮文件不支持是Windows 10或Python 3.5。

任何帮助将不胜感激。

+0

你有没有尝试下载命名为你的Python版本的文件? (cp3 ** 5 **,而不是cp3 ** 6 **) – MatsLindh

+0

'lxml'需要C/C++库'libxml2','libxslt' - 您无法使用'pip'安装它们 – furas

+0

@MatsLindh对不起,我试过CP36和以前的CP35,但只复制粘贴后来的输出,我编辑我的问题。所以是的,我尝试了并得到完全相同的结果。 – Djidiouf

回答

3

lxmllibxml2使用,libxslt(背景),但libxml2libxslt不是Python模块 - 它是C/C++库。所以你不能用pip来安装它们。您必须手动下载并安装它们。

您可以在Unofficial Windows Binaries for Python Extension Packages

  • cp35找到适用于Windows预编译lxml在文件名字的意思是版本为Python 3.5。
  • win32文件名意味着版本为32位Python。
  • amd64文件名意味着版本为64位Python。

你可能使用32位Python的,因为我看到32(x86)在您的路径

C:\program files (x86)\python35-32\python.exe 

你应该找到这个页面上的链接libxml2libxslt了。这些库具有.dll和.exe文件,您可以将它们放入任何位于PATH变量中的文件夹中。图书馆大多安装在C:\Windows或子文件夹中。

libxml2libxslt也可能有C/C++头文件*.h,当你编译lxml你可能需要。 (在Linux上这个文件是分开包装 libxml2-devlibxslt-dev


BTW:您可以使用Anaconda分布(而不是Python.org分布)。它安装相同的Python,但有一些预编译模块 - 即。它会自动安装lxmlAnaconda可以成为Windows用户的最佳解决方案。

所有模块的列表:https://docs.continuum.io/anaconda/pkg-docs