我首先尝试为它运行基本的pip install命令:
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,但它也需要libxml2依赖项。
从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 :(得分:3)
lxml
使用libxml2
,libxslt
(在后台),但libxml2
,libxslt
不是Python模块 - 它是C / C ++库。所以你不能用pip安装它们。您必须手动下载并安装它们。
您可以在Unofficial Windows Binaries for Python Extension Packages
上找到适用于Windows的预编译lxml
cp35
表示Python 3.5的版本。 win32
表示32位Python的版本。 amd64
表示64位Python的版本。 您可能使用32位Python,因为我在您的路径中看到32
和(x86)
C:\program files (x86)\python35-32\python.exe
您也应该在此页面上找到指向libxml2
,libxslt
的链接。此库具有.dll和.exe文件,您可以将它们放在PATH
变量中的任何文件夹中。库主要安装在C:\Windows
或子文件夹中。
libxml2
,libxslt
也可能包含编译*.h
时可能需要的C / C ++头文件lxml
。 (在Linux上,这些文件位于独立的包中
libxml2-dev
,libxslt-dev
)
BTW:您可以使用Anaconda
分发(而不是Python.org
分发)。它安装相同的Python,但安装了一些预编译模块 - 即。它会自动安装lxml
。 Anaconda
可以是Windows用户的最佳解决方案。
答案 1 :(得分:0)
另外,检查您的pip --version。我安装了v19.0,并且无法安装Gohlke .whl二进制文件。升级到19.2或更高版本。