在Windows 10上为Python 3.5安装lxml,libxml2,libxslt [英] Installing lxml, libxml2, libxslt for Python 3.5 on Windows 10

查看:487
本文介绍了在Windows 10上为Python 3.5安装lxml,libxml2,libxslt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我首先尝试为其运行基本的pip install命令:

I first try to run the basic pip install command for it:

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:

I tried to install 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:

And I also tried to install 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

我还尝试从源代码构建lxml( https://github.com/lxml/lxml),但它也需要libxml2依赖项.

I also tried to build lxml from sources ( https://github.com/lxml/lxml ) but it needs the libxml2 dependencies as well.

下载了lxml文件后,我也尝试通过wheel安装它. http://www.lfd.uci.edu/~gohlke/pythonlibs/#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.

It seems that this wheel file doesn't support either Windows 10 or Python 3.5.

任何帮助将不胜感激.

推荐答案

lxml使用libxml2libxslt(在后台),但是libxml2libxslt不是Python模块-它是C/C ++库.因此,您无法使用pip安装它们.您必须手动下载并安装它们.

lxml uses libxml2, libxslt (in background) but libxml2, libxslt are not Python modules - it's C/C++ libraries. So you can't install them using pip. You have to download and install them manually.

您可以在针对Windows的非官方Windows二进制文件中找到Windows的预编译lxml Python扩展包

You can find precompiled lxml for Windows on Unofficial Windows Binaries for Python Extension Packages

    文件名中的
  • cp35表示Python 3.5的版本.
  • 文件名中的
  • win32表示32位Python的版本.
  • 文件名中的
  • amd64表示64位Python的版本.
  • cp35 in file name means version for Python 3.5.
  • win32 in file name means version for 32bit Python.
  • amd64 in file name means version for 64bit Python.

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

You probably use 32bit Python because I see 32 and (x86) in your path

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

您也应该在此页面上找到指向libxml2libxslt的链接.该库具有.dll和.exe文件,您可以将它们放在PATH变量中的任何文件夹中.库大多安装在C:\Windows或子文件夹中.

You should find links to libxml2, libxslt on this page too. This libraries has .dll and .exe files and you can put them in any folder which is in PATH variable. Libraries mostly are installed in C:\Windows or in subfolder.

libxml2libxslt可能还具有C/C ++头文件*.h,在编译lxml时可能需要这些文件. (在Linux上,此文件位于单独的程序包中 libxml2-devlibxslt-dev)

libxml2, libxslt may have also C/C++ header files *.h which you may need when you compile lxml. (on Linux this files are in separated packages libxml2-dev, libxslt-dev)

顺便说一句:您可以使用Anaconda发行版(而不是Python.org发行版).它安装了相同的Python,但带有一些预编译的模块-即.它会自动安装lxml. Anaconda可能是Windows用户的最佳解决方案.

BTW: You can use Anaconda distribution (instead of Python.org distribution). It installs the same Python but with some precompiled modules - ie. it installs lxml automatically. Anaconda can be the best solution for Windows users.

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

这篇关于在Windows 10上为Python 3.5安装lxml,libxml2,libxslt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆