Python无法找到或安装lxml

时间:2015-07-31 16:25:43

标签: windows python-3.x pandas

在Win7中,在python 3.4中,在pandas中,我尝试运行pd.read_html。 它流产,说它找不到lxml。 我添加了“import lxml”,它说没有那个名字的模块。

我跑了“pip install pandas lxml”,它中止,说

C:\Python34\hsf\pandas>pip install pandas lxml

Requirement already satisfied (use --upgrade to upgrade): pandas in c:\python34\
lib\site-packages

Downloading/unpacking lxml

  Running setup.py (path:C:\Users\Windows\AppData\Local\Temp\pip_build_Windows\l
xml\setup.py) egg_info for package lxml

    Building lxml version 3.4.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 *
*

我试着用pip来安装libxml2和libxslt,然后中止说:

C:\Python34\lib\distutils\dist.py:260: UserWarning: Unknown distribution option:
 'bugtrack_url'

  warnings.warn(msg)

error: Unable to find vcvarsall.bat

之前SO对类似问题的回答说“使用sudo ......”因此不适用于Windows。

如何在Win7上的python 3.4中安装lxml?

1 个答案:

答案 0 :(得分:0)

您可以尝试以下操作:

pip install lxml

对于vcvarvasall.bat,您可以尝试安装:https://www.microsoft.com/en-us/download/details.aspx?id=44266

如果这些都不起作用,您可以在此处下载预编译的二进制文件: http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

最后一个选项是最简单的。以下是步骤: 1)在http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml下载方向盘 2)pip install wheel 3) pip install"从步骤1&#34下载* .whl的路径;