Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

installing pandas on python - where did numpy go?

Tags:

python

url

excel

So I'm trying to open a website/url extract an excel file on the site, edit it, and then put it on a different website. I found another comment on this site that has excellent advice for how to do this using import pandas. I downloaded pandas (and some other modules) from the python website, and wrote the code. But when I try to run it I get the following error

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 

What is going on?

Is there an easier way to download the excel file from the internet?

I just started coding with Python last week so I'm still confused with some simple things.

like image 330
Isa Avatar asked Jun 12 '14 22:06

Isa


1 Answers

Update: Pandas 0.15.2 has been released, and it works pretty well with the most current version of openpyxl (2.0 or later). This answer is outdated.


OK, it appears that you have obtained the most recent version of pandas (==0.14.0), and this one requires some specific version of the Openpyxl. If you don't care about giving up new features introduced in newer version, try uninstall your existing openpyxl and install an older version.

pip uninstall openpyxl
pip install openpyxl==1.8.6

If you simply want to download the file and save it to a local folder, here is an easier way:

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")
like image 174
JimmyK Avatar answered Sep 30 '22 19:09

JimmyK