【问题标题】:installing pandas on python - where did numpy go?在 python 上安装 pandas - numpy 去哪儿了?
【发布时间】:2014-08-03 09:34:55
【问题描述】:

所以我试图打开一个网站/url 在网站上提取一个 excel 文件,对其进行编辑,然后将其放在另一个网站上。我在这个网站上发现了另一条评论,它对如何使用 import pandas 进行此操作提供了很好的建议。 我从 python 网站下载了 pandas(和其他一些模块),并编写了代码。但是当我尝试运行它时,出现以下错误

Warning (from warnings module):
  File "C:\Python27\lib\site-packages\pandas\io\excel.py", line 626
    .format(openpyxl_compat.start_ver, openpyxl_compat.stop_ver))
UserWarning: Installed openpyxl is not supported at this time. Use >=1.6.1 and <2.0.0.
Traceback (most recent call last):
  File "C:\Python27\more_url_stuff.py", line 6, in <module>
    socket = urllib2.urlopen(link)
  File "C:\Python27\lib\urllib2.py", line 127, in urlopen
    return _opener.open(url, data, timeout)
  File "C:\Python27\lib\urllib2.py", line 410, in open
    response = meth(req, response)
  File "C:\Python27\lib\urllib2.py", line 523, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python27\lib\urllib2.py", line 448, in error
    return self._call_chain(*args)
  File "C:\Python27\lib\urllib2.py", line 382, in _call_chain
    result = func(*args)
  File "C:\Python27\lib\urllib2.py", line 531, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 401: Unauthorized 

发生了什么事?

有没有更简单的方法可以从网上下载excel文件?

我上周刚开始使用 Python 编码,所以我仍然对一些简单的事情感到困惑。

【问题讨论】:

  • 注意这一行:Warning: Installed openpyxl is not supported at this time. Use &gt;=1.6.1 and &lt;2.0.0.。你的openpyxl是什么版本的?
  • 谢谢 - 我会努力解决这个问题。我什至不确定是哪个警告导致了所有问题。
  • 我在哪里可以获得比 2.0.3 更早的 openpyxl 版本?

标签: python excel url


【解决方案1】:

更新: Pandas 0.15.2 已经发布,它可以很好地与最新版本的 openpyxl(2.0 或更高版本)配合使用。这个答案已经过时了。


好的,看来您已经获得了最新版本的 pandas (==0.14.0),而这需要一些特定版本的 Openpyxl。如果您不介意放弃新版本中引入的新功能,请尝试卸载现有的 openpyxl 并安装旧版本。

pip uninstall openpyxl
pip install openpyxl==1.8.6

如果您只是想下载文件并将其保存到本地文件夹,这里有一个更简单的方法:

import urllib
URL_to_the_file = "http://real-chart.finance.yahoo.com/table.csv?s=SPY&a=00&b=29&c=1993&d=05&e=13&f=2014&g=d&ignore=.csv"
urllib.urlretrieve (URL_to_the_file, "downloaded.csv")

【讨论】:

  • 对新手(像我一样)的澄清,pip ...指令在OS shell命令中执行,而不是在python shell中。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-03-03
  • 2014-03-15
  • 2015-07-17
  • 2012-10-30
  • 2013-05-23
  • 1970-01-01
相关资源
最近更新 更多