【问题标题】:Python can't find or install lxmlPython 找不到或安装 lxml
【发布时间】:2015-07-31 16:25:42
【问题描述】:

在 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?

【问题讨论】:

    标签: windows python-3.x pandas


    【解决方案1】:

    您可以尝试以下方法:

    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 步下载 *.whl 的路径"

    【讨论】:

    • 叹息!下载并运行 C:\Perl>pip install C:\Documents and Settings\Windows\Downloads\lxml-3.4.4-cp34- none-win32.whl -- 屏幕上满是不可读的红色墨水。
    • 您使用的是 32 位还是 64 位?我认为它不起作用,试试这个轮子:lxml‑3.4.4‑cp34‑none‑win_amd64.whl
    • 另一个带有红色墨水的屏幕。最后一行说: ValueError: ('Expected version spec in', 'C:\\Documents', 'at', ':\\Documents')。我不知道那是什么意思。看起来自己抓取文件(这就是我现在正在做的事情)比下载文件以使其“更容易”更容易。
    • 我能给出的唯一其他建议是确保不要在 .whl 文件所在的同一文件夹中运行 pip install
    猜你喜欢
    • 2019-01-11
    • 1970-01-01
    • 2019-04-15
    • 1970-01-01
    • 1970-01-01
    • 2016-01-20
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    相关资源
    最近更新 更多