【问题标题】:Receving an error when trying to use the pandas read_html function尝试使用 pandas read_html 函数时收到错误
【发布时间】:2017-01-14 11:42:40
【问题描述】:

我对 python 和 pandas 真的很陌生,所以我可能会犯一个简单的错误。

我正在尝试运行以下代码:

import quandl
import pandas as pd

df3 = pd.read_html('https://simple.wikipedia.org/wiki/List_of_U.S._states')
print(df3)

我已经通过 pip 安装了 pandas 以及 quandl。 当我运行代码时,出现以下错误:

Traceback (most recent call last):
File "C:\Python27\FunwithQuandl.py", line 14, in <module>
df3 = pd.read_html('https://simple.wikipedia.org /wiki/List_of_U.S._states')
File "C:\Python27\lib\site-packages\pandas\io\html.py", line 874, in read_html
parse_dates, tupleize_cols, thousands, attrs, encoding)
File "C:\Python27\lib\site-packages\pandas\io\html.py", line 726, in _parse
parser = _parser_dispatch(flav)
File "C:\Python27\lib\site-packages\pandas\io\html.py", line 685, in _parser_dispatch
raise ImportError("lxml not found, please install it")
ImportError: lxml not found, please install it

然后我尝试通过命令提示符和 pip 安装 lxml,但出现了一些错误:

Cannnot open include file: 'libxml/xpath.h': No such file or directory

Could not find function xmlCheckVersion in library libxm12. Is libxml2 installed?

error: command 'CL\\User\\...Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

我什至尝试过 this thread 的建议:

"从 lfd.uci.edu/~gohlke/pythonlibs/#lxml 安装 lxml 蟒蛇版本。这是一个预编译的 WHL,需要 模块/依赖项。

该网站列出了几个包,例如使用 Win32 Python 2.7,使用 lxml-3.6.1-cp27-cp27m-win32.whl。”

我已从建议的站点下载了 whl 文件,但我似乎无法安装它。 我曾尝试使用 pip 并输入文件名,但无法通过 pip 识别该文件。

我正在使用 Python 2.7 和 Windows 7 专业版

感谢您的帮助。

【问题讨论】:

  • 当您尝试使用 pip 安装 whl 文件时,它是否返回任何消息?
  • 你见过this吗?
  • 我解决了这个问题。当文件位于我的用户名目录中时,我将文件从“Downloads”移动到“LocalDisk/Users/myname”,PIP 由于某种原因能够找到并安装它。感谢您的回复。
  • 太好了!现在,您找到了答案,您能否将其写为答案,然后将其标记为正确答案。这样,其他人就会很容易找到答案。另外,请看this

标签: python windows python-2.7 pandas pip


【解决方案1】:

我解决了这个问题。我将要安装的文件从Downloads 移动到LocalDisk/Users/My_name。在正确的目录中,PIP 由于某种原因能够找到并安装它。感谢您的回复。

【讨论】:

    【解决方案2】:

    我在配置 pandas 时遇到了类似问题,我认为同样的原因是我使用的是 windows x64 机器,而我的 pip 包正在安装 win32 .whl 文件.

    我真的很不高兴,直到我找到https://www.lfd.uci.edu/~gohlke/pythonlibs/ 这是我能够获得 winx64 兼容模块的站点,我后来在本地使用 pip 来安装我的包,然后问题得到解决。 (请注意:提供的链接仅包含适用于 Windows 的 Python 包)。

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 2015-09-06
      • 2017-01-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-14
      • 2016-10-08
      • 1970-01-01
      相关资源
      最近更新 更多