当我尝试在我的Windows 7机器上使用pip升级lxml时,我得到下面打印的日志 .
当我卸载并尝试从头开始安装时,我得到了同样的错误 . 有任何想法吗?
从https://pypi.python.org/packages/source/l/lxml/l xml-3.2.4.tar.gz下载/解包lxml#md5 = cc363499060f615aca1ec8dcc04df331正在下载lxml-3.2.4.tar.gz(3.3 MB):3.3MB下载运行setup.py egg_info for package lxml Building lxml version 3.2.4 . 没有Cython的建筑 . 错误:Nazwa'xslt-config'nie jest rozpoznawana jakopoleceniewewnętrznelubzewnętrzne,program wykonywalny lub plik wsadowy . *确保安装了libxml2和libxslt的开发包
*使用libxslt的构建配置
D:\ software \ Python27 \ lib \ distutils \ dist.py:267:UserWarning:未知的分发选项:'bugtrack_url'
warnings.warn(MSG)
警告:在目录'src \ lxml'下找不到匹配'lxml.etree.c'的文件
警告:在目录'src \ lxm l'下找不到匹配'lxml.objectify.c'的文件
警告:在目录'src \ lxml'下找不到匹配'lxml.etree.h'的文件
警告:在目录'src \ lxm l'下找不到匹配'lxml.etree_api.h'的文件
警告:在目录'src \ lxml'下找不到匹配'etree_defs.h'的文件
警告:在目录'src \ lxml \ tests'下找不到匹配'* .txt'的文件
警告:找不到与'doc'目录下的'pubkey.asc'匹配的文件
警告:找不到与'doc'目录下的'tagpython * .png'匹配的文件
警告:找不到与'doc'目录下的'Makefile'匹配的文件安装收集的包:lxml找到现有安装:
lxml 2.3卸载lxml:成功卸载lxml运行setup.py install for lxml Building lxml version 3.2.4 . 没有Cython的建筑 . 错误:Nazwa'xslt-config'nie jest rozpoznawana jakopoleceniewewnętrznelubzewnętrzne,program wykonywalny lub plik wsadowy . *确保安装了libxml2和libxslt的开发包
*使用libxslt的构建配置
Build 'lxml.etree'扩展
D:\ software \ Microsoft Visual Studio 9.0 \ VC \ BIN \ cl.exe / c / nologo / Ox / MD / W3 / GS- / DNDEBUG
-Ic:\ users \ x \ appdata \ local \ temp \ pip_build_x \ lxml \ src \ lxml \ inc ludes -ID:\ software \ Python27 \ include -ID:\ software \ Python27 \ PC / Tcsrc \ lxml \ lxml . etree.c /Fobuild\temp.win32-2.7\Release\src\lxml\lxml.etree.obj lxml.etree.cc:\ users \ x \ appdata \ local \ temp \ pip_build_x \ lxml \ src \ lxml \ includes \ etree_d efs.h(9):致命错误C1083:无法打开包含文件:'libxml / xmlversion.h':N o这样的文件或目录D:\ software \ Python27 \ lib \ distutils \ dist.py:267:UserWarning:未知的分发选项:'bugtrack_url'warnings.warn(msg)错误:命令'“D:\ software \ Microsoft Visual Studio 9.0 \ VC \ BIN \ cl.exe”'fai以退出状态2结束从命令D完成输出: \ software \ Python27 \ python.exe -c“import setu ptools; file ='c:\ users \ x \ appdata \ local \ temp \ pip_build_x \ lxml \ setu p.py'; exec(compile(open(file) . read() . replace('\ r \ n','\ n'),file,'exec'))“install --record c:\ users \ x \ appdata \ local \ temp \ pip-pyyuss-record \ install-r ecord.txt --single-version-external-managed:构建lxml版本3.2.4 . 没有Cython的建筑 . 错误:Nazwa'xslt-config'nie jest rozpoznawana jakopoleceniewewnętrznelubzewnętrzne,program wykonywalny lub plik wsadowy . 确保安装了libxml2和libxslt的开发包使用libxslt的构建配置运行安装运行构建运行build_py创建构建创建build \ lib.win32-2.7创建build \ lib.win32-2.7 \ lxml复制src \ lxml \ builder.py - > build \ lib.win32-2.7 \ lxml复制src \ lxml \ cssselect.py - > build \ lib.win32-2.7 \ lxml复制src \ lxml \ doctestcompare.py - > build \ lib.win32- 2.7 \ lxml复制src \ lxml \ ElementInclude.py - > build \ lib.win32-2.7 \ lxml复制src \ lxml \ pyclasslookup.py - > build \ lib.win32-2.7 \ lxml复制src \ lxml \ sax.py - > build \ lib.win32-2.7 \ lxml复制src \ lxml \ usedoctest.py - > build \ lib.win32-2.7 \ lxml复制src \ lxml_elementpath.py - > build \ lib.win32-2.7 \ lxml复制src \ lxml__init__ .py - > build \ lib.win32-2.7 \ lxml创建build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes__init __ . py - > build \ lib.win32-2.7 \ lxml \ includes包含创建build \ lib .win32-2.7 \ lxml \ html复制src \ lxml \ html \ builder.py - > build \ lib.win32-2.7 \ lxml \ html复制s rc \ lxml \ html \ clean.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html \ defs.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html \ diff.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html \ ElementSoup.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html \ formfill.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html \ html5parser.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html \ soupparser.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html \ usedoctest . py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html_diffcommand.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html_html5builder.py - > build \ lib.win32 -2.7 \ lxml \ html复制src \ lxml \ html_setmixin.py - > build \ lib.win32-2.7 \ lxml \ html复制src \ lxml \ html__init __ . py - > build \ lib.win32-2.7 \ lxml \ html创建构建\ lib.win32-2.7 \ lxml \ isoschematron复制src \ lxml \ isoschematron__init __ . py - > build \ lib.win32-2.7 \ lxml \ isoschema tron复制src \ lxml \ lxml.etree.h - > build \ lib.win32- 2.7 \ lxml复制src \ lxml \ lxml.etree_api.h - > build \ lib.win32-2.7 \ lxml复制src \ lxml \ includes \ c14n.pxd - > build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes \ config.pxd - > build \ lib.win32-2.7 \ lxml \包括复制src \ lxml \ includes \ dtdvalid.pxd - > build \ lib.win32-2.7 \ lxml \ includes复制src \ lxml \ includes \ etreepublic.pxd - > build \ lib.win32-2.7 \ lxml \ includes复制src \ lxml \ includes \ htmlparser.pxd - > build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes \ relaxng.pxd - > build \ lib.win32-2.7 \ lxml \ includes复制src \ lxml \ includes \ schematron.pxd - > build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes \ tree.pxd - > build \ lib.win32-2.7 \ lxml \ includes复制src \ lxml \ includes \ uri.pxd - > build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes \ xinclude.pxd - > build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes \ xmlerror.pxd - > build \ lib.win32-2.7 \ lxml \包括复制src \ lxml \ includes \ xmlparser.pxd - > build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes \ xmlschema.pxd - > build \ lib.win32- 2.7 \ lxml \包括复制src \ lxml \ includes \ xpath.pxd - > build \ lib.win32-2.7 \ lxml \包含复制src \ lxml \ includes \ xslt.pxd - > build \ lib.win32-2.7 \ lxml \包括复制sr c \ lxml \ includes \ etree_defs.h - > build \ lib.win32-2.7 \ lxml \包括复制src \ lxml \ includes \ lxml-version.h - > build \ lib.win32-2.7 \ lxml \ includes包含创建构建\ lib.win32-2.7 \ lxml \ isoschematron \ resources创建build \ lib.win32-2.7 \ lxml \ isoschematron \ resources \ rng复制src \ lxml \ isoschematron \ resources \ rng \ iso-schematron.rng - > build \ lib.win 32-2.7 \ lxml \ isoschematron \ resources \ rng创建build \ lib.win32-2.7 \ lxml \ isoschematron \ resources \ xsl复制src \ lxml \ isoschematron \ resources \ xsl \ RNG2Schtrn.xsl - > build \ lib.win32-2 .7 \ lxml \ isoschematron \ resources \ xsl复制src \ lxml \ isoschematron \ resources \ xsl \ XSD2Schtrn.xsl - > build \ lib.win32-2 .7 \ lxml \ isoschematron \ resources \ xsl created build \ lib.win32- 2.7 \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xsl t1复制src \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xslt1 \ iso_abstract_e xpand.xsl - > build \ lib.win32-2.7 \ lxml \ isoschematron \ resources \ xsl \ iso-schematron -xslt1复制src \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xslt1 \ iso_dsdl_inclu de.xsl - > build \ lib.win32-2.7 \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xs lt1复制src \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xslt1 \ iso_schematron _message.xsl - > build \ lib.win32-2.7 \ lxml \ isoschematron \ resources \ xsl \ iso-schemat ron-xslt1复制src \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xslt1 \ iso_schematron skeleton_for_xslt1.xsl - > build \ lib . win32-2.7 \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xslt1复制src \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xslt1 \ iso_svrl_for_x slt1.xsl - > build \ lib.win32-2.7 \ lxml \ isoschematron \ resources \ xsl \ iso-schematron- xslt1复制src \ lxml \ isoschematron \ resources \ xsl \ iso-schematron-xslt1 \ readme.txt - > build \ lib.win32-2.7 \ lxml \ isoschematron \ resources \ xsl \ iso -schematron-xslt1运行build_ext构建'lxml.etree'扩展创建build \ temp.win32-2.7创建build \ temp.win32-2.7 \发布创建build \ temp.win32-2.7 \ Release \ src创建build \ temp.win32- 2.7 \ Release \ src \ lxml D:\ software \ Micr osoft Visual Studio 9.0 \ VC \ BIN \ cl.exe / c / nologo / Ox / MD / W3 / GS - / DNDEBUG -Ic:\ users \ x \ appdata \ local \ temp \ pip_build_x \ lxml \ src \ lxml \ include s -ID:\ software \ Python27 \ include -ID:\ software \ Python27 \ PC /Tcsrc \ lxml \ lxml.etre ec /Fobuild\temp.win32-2.7\Release\src\lxml\lxml.etree.obj lxml . etree.cc:\users\x\appdata\local\temp\pip_build_x\lxml\src\lxml\includes\etree_defs . h(9):致命错误C1083:无法打开包含文件:'libxml / xmlversion.h':没有文件或目录D:\ software \ Python27 \ lib \ distutils \ dist.py:267:UserWarning:未知的分发选项:'bugtrack_url'warnings.warn(msg)错误:命令'“D:\ software \ Microsoft Visual Studio 9.0 \ VC \ BIN \ cl.exe“'以退出状态2失败-------------------------------------- - 回滚卸载lxml清理...命令D:\ software \ Python27 \ python.exe -c“import setuptools; file ='c:\ user s \ x \ appdata \ local \ temp \ pip_build_x \ lxml \ setup.py'; exec(compile(open( file _) . read() . replace('\ r \ n','\ n'),file,'exec'))“install --record c:\ u sers \ x \ appdata \ local \ temp \ pip-pyyuss-record \ install-record.txt --s--versio n-external-managed失败,错误代码1在c:\ users \ x \ appdata \ local \ temp \ pip_build_x \ lxml Traceback(最近一次调用最后一次):文件“D:\ software \ Python27 \ Scripts \ pip-script.py”,第9行,在load_entry_point中('pip == 1.4.1','console_scripts','pip ')()文件“D:\ software \ Python27 \ lib \ site-packages \ pip__init __ . py”,第148行,在ma中返回command.main(args [1:],options)文件“D:\ softwar e \ Python27 \ lib \ site-packages \ pip \ basecommand.py“,第169行,主文本='\ n'.join(complete_log)UnicodeDecodeError:'ascii'编解码器无法解码位置72的字节0xa9:序数不在范围内(128)
8 回答
如果您安装了编译器(使用VS C 2008 Express测试),则只需运行:
set STATICBUILD=true && pip install lxml
正如on documentation所指出的,设置
STATICBUILD
将告诉lxml的安装程序在构建之前自动下载其所有二进制依赖项 .这些
lxml
二进制依赖项(从源代码安装时应该存在)将由安装程序下载并一起构建:libxslt
iconv
zlib
libxml2
Bonus :它也适用于virtualenv .
这个问题较旧但仍会在谷歌中弹出 . 我尝试了这个问题的其他答案,但由于某种原因它们无法正常工作,我不想跟踪并安装所有依赖项以在Windows上编译 .
我注意到在pypi上,一些lxml版本提供了windows轮子而其他版本没有 .
所以对我来说最简单的解决方案是指定一个版本......即
pip install lxml==3.6.0
,因为3.6.0提供了一个轮子,而较新的3.6.4没有对于您的问题,有一个单行解决方案 . 不知何故,这是工作意味着你假设你正在低水平刮,然后这将工作 .
经过8个小时的研究,我发现这没什么用
不需要其他任何东西 .
以上所有内容均适用于Windows .
评论是否有其他类型的问题持续乐意提供帮助 .
这是我8小时后的成功:
您可以执行Flak's answer中的步骤,或者只需download the Windows installer,双击即可启动它,然后继续前进 .
These instructions are for Windows7 or Windows8 with Python2.7 .
However ,它们应该适用于各种版本,因为python和其他各自的先决条件的发布会改变/发展:
安装 Python2.7 :
从下载页面下载最新版本的Python2.7(目前为2.7.6)HERE
Win32 MSI安装程序的直接链接 - > HERE
Win64 MSI安装程序的直接链接 - > HERE
只需运行MSI即可安装python . 它将在注册表中注册,并显示在“添加/删除程序”中 .
NOTE: 以下说明假设您在Python安装向导中询问时选择将python安装到
C:\python27\
的默认路径将
C:\python27\
和C:\python27\scripts
文件夹添加到系统路径,方法是将这些目录添加到 Control Panel > System > Advanced System Settings link (Advanced Tab) > Environmental Variables (Button) 的PATH
环境变量中 .(可选)安装 OpenSSL :
从HERE下载 Win32 OpenSSL page ,以获取适用于您的Windows和PC架构的版本
下载 Visual C++ 2008 redistributables 为您的Windows和PC架构版本
下载 OpenSSL 为您的Windows和体系结构版本(常规版本,而不是轻量级版本)
将以下(取决于您的体系结构)目录(或您安装到的任何地方)添加到
PATH
,与上面添加C:\python27
和C:\python27\scripts
的方式相同:32-bit:
c:\openssl-win32\bin
64-bit:
c:\openssl-win64\bin
安装 Setuptools (
get-pip.py
应该为你安装Setuptools),但是,为了以防万一...下载
ez_setup.py
HERE并将其保存在C:\python27\scripts
中运行 C:\python27\scripts> python ez_setup.py
安装 PIP
从HERE下载
get-pip.py
并将其保存在C:\python27\scripts
中运行 C:\python27\scripts> python get-pip.py
安装 LXML
从HERE下载
LXML 3.3.3
,以获取适用于您的Windows和PC架构的版本运行EXE文件
lxml网站上的常见问题解答指向一个为Windows创建二进制发行版的网站:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
可以使用pip安装车轮 .
https://pip.pypa.io/en/latest/user_guide/#installing-from-wheels
您需要在虚拟环境中安装libxml,libxslt,libiconv和zlib . 你还需要VS 2008,因为python 2.7是针对该版本编译的 . 我在这里写了一个更详细的解释http://www.laurivan.com/install-lxml-on-windows-on-a-virtualenv/
我已经安装了(VS C 2014 Express)直接pip安装失败但添加了以下借用 Fernando Macedo set STATICBUILD = true && pip install lxml这对我来说在windows 10上使用Python 3.5.2,lxml 3.6.4在virtualenv中工作了
\ DDSHARMA \文件\ pymote_env>