Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spyper cannot read yahoo stock price #2569

Closed
israelyk opened this issue Jul 28, 2015 · 10 comments
Closed

Spyper cannot read yahoo stock price #2569

israelyk opened this issue Jul 28, 2015 · 10 comments

Comments

@israelyk
Copy link

I recently installed Spyder, however, I cannot fetch stock price from Yahoo using IPhython console.
However, when I use separate IPhython console, I could do it successfully.

What steps will reproduce the problem?

  1. in Spyder's IPythone console
    run the folowing scripts:
import pandas
import pandas.io.data as web
from datetime import datetime
start = datetime(2014,1,1)
end = datetime(2014,12,31)
st = web.DataReader('IBM', 'yahoo', start, end)
  1. Here is the information:
  File "<ipython-input-6-bef31b32ea02>", line 1, in <module>
    st = web.DataReader('IBM', 'yahoo', start, end)

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 77, in DataReader
    retry_count=retry_count, pause=pause)

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 424, in get_data_yahoo
    adjust_price, ret_index, chunksize, 'yahoo')

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 365, in _get_data_from
    hist_data = src_fn(symbols, start, end, interval, retry_count, pause)

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 208, in _get_hist_yahoo
    return _retry_read_url(url, retry_count, pause, 'Yahoo!')

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 185, in _retry_read_url
    "return a 200 for url %r" % (retry_count, name, url))

IOError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.finance.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2014&d=11&e=31&f=2014&g=d&ignore=.csv'


In [7]: runfile('C:/Users/502407443/Documents/Python Scripts/ReadPrice.py', wdir='C:/Users/502407443/Documents/Python Scripts')
Traceback (most recent call last):

  File "<ipython-input-7-ac6f45c5535c>", line 1, in <module>
    runfile('C:/Users/502407443/Documents/Python Scripts/ReadPrice.py', wdir='C:/Users/502407443/Documents/Python Scripts')

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 685, in runfile
    execfile(filename, namespace)

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 71, in execfile
    exec(compile(scripttext, filename, 'exec'), glob, loc)

  File "C:/Users/502407443/Documents/Python Scripts/ReadPrice.py", line 13, in <module>
    st = web.DataReader('IBM', 'yahoo', start, end)

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 77, in DataReader
    retry_count=retry_count, pause=pause)

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 424, in get_data_yahoo
    adjust_price, ret_index, chunksize, 'yahoo')

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 365, in _get_data_from
    hist_data = src_fn(symbols, start, end, interval, retry_count, pause)

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 208, in _get_hist_yahoo
    return _retry_read_url(url, retry_count, pause, 'Yahoo!')

  File "C:\Users\502407443\AppData\Local\Continuum\Anaconda\lib\site-packages\pandas\io\data.py", line 185, in _retry_read_url
    "return a 200 for url %r" % (retry_count, name, url))

IOError: after 3 tries, Yahoo! did not return a 200 for url 'http://ichart.finance.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2014&d=11&e=31&f=2014&g=d&ignore=.csv'

What is the expected output? What do you see instead?
when I use separate IPhython console, I could do it successfully.

Please provide any additional information below

Version and main components

Spyder 2.3
Python 2.7.10 |Anaconda 2.3.0 (64-bit)| (default, May 28 2015, 16:44:52) [MSC v.1500 64 bit (AMD64)] on win32

  • Spyder Version: 2.3.5.2
  • Python Version: 2.7.10
  • Qt Versions: 4.8.6, PyQt4 (API v2) 4.10.4 on Windows

IPython >=1.0 : 3.2.0 (OK)
jedi >=0.8.1 : 0.8.1 (OK)
matplotlib >=1.0: 1.4.3 (OK)
pandas >=0.13.1 : 0.16.2 (OK)
pep8 >=0.6 : 1.6.2 (OK)
pyflakes >=0.5.0: 0.9.2 (OK)
pygments >=1.6 : 2.0.2 (OK)
pylint >=0.25 : None (NOK)
rope >=0.9.2 : 0.9.4 (OK)
sphinx >=0.6.6 : 1.3.1 (OK)
sympy >=0.7.3 : 0.7.6 (OK)
zmq >=2.1.11 : 14.7.0 (OK)

@israelyk
Copy link
Author

I debug it, the code analysis says:
pandas imported but unused

@ccordoba12
Copy link
Member

I don't understand. How exactly did you debug this problem? And what can we do to solve it?

@israelyk
Copy link
Author

in the Spyder screen, I click the debug and click run the file which
contains these commands, it showed a tiny red triangle mark, put the mouse
on it, it says code analysis:
Pandas imported but unused

I installed Spyder through installation of Anaconda, should I reinstalled
Spyder again?

On Tue, Jul 28, 2015 at 2:38 PM, Carlos Cordoba [email protected]
wrote:

I don't understand. How exactly did you debug this problem? And what can
we do to solve it?


Reply to this email directly or view it on GitHub
#2569 (comment).

@israelyk
Copy link
Author

When I run the same command lines at Wakari IPython console it works very
well

On Tue, Jul 28, 2015 at 2:38 PM, Carlos Cordoba [email protected]
wrote:

I don't understand. How exactly did you debug this problem? And what can
we do to solve it?


Reply to this email directly or view it on GitHub
#2569 (comment).

@israelyk
Copy link
Author

I believe some thing wrong with the Spyder IPython Console

On Tue, Jul 28, 2015 at 3:26 PM, Israel Kang [email protected] wrote:

When I run the same command lines at Wakari IPython console it works very
well

On Tue, Jul 28, 2015 at 2:38 PM, Carlos Cordoba [email protected]
wrote:

I don't understand. How exactly did you debug this problem? And what can
we do to solve it?


Reply to this email directly or view it on GitHub
#2569 (comment)
.

@JimHokanson
Copy link

The failure comes from a http request. I'd be surprised if this was due to the Spyder console. Can you make the request on your browser?
http://ichart.finance.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2014&d=11&e=31&f=2014&g=d&ignore=.csv

Also, does the code still not work in Spyder? It's not uncommon for some sites to occasionally not work and for the requests to go through at later times (due to a temporary server outage or high load).

Wakari on the other hand is running on a remote server and sending the results back to you. If for some reason your network was blocking data from yahoo I'd expect Wakari to work and Spyder to not.

You could also try looking at what the http status code is that is being returned. It not being a "200" is rather vague (see pandas\io\data.py", line 185, in _retry_read_url).

Regarding Pandas being imported but not used, that is simply a reference to the fact that you imported the Pandas module but never refer to it in the code.

import pandas
#You never have pandas.<anything> like pandas.DataFrame (the 2nd import doesn't count)

Just remove the first line. It isn't causing any harm but it looks weird.

import pandas.io.data as web #works fine, you don't need a import pandas before hand

@israelyk
Copy link
Author

Hi Jim,

I click on the link
http://ichart.finance.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2014&d=11&e=31&f=2014&g=d&ignore=.csv
it starts to download the csv file to my computer.

It still does not work from Spyder Ipython console. Thanks for the comment
regarding the pandas.

It could possibly my company's server block me accessing the data from
Yahoo.

Do you have any ways to suggest me to verify this is the case?

Thanks a lot

Israel

On Tue, Jul 28, 2015 at 5:59 PM, Jim Hokanson [email protected]
wrote:

The failure comes from a http request. I'd be surprised if this was due to
the Spyder console. Can you make the request on your browser?

http://ichart.finance.yahoo.com/table.csv?s=IBM&a=0&b=1&c=2014&d=11&e=31&f=2014&g=d&ignore=.csv

Also, does the code still not work in Spyder? It's not uncommon for some
sites to occasionally not work and for the requests to go through at later
times (due to a temporary server outage or high load).

Wakari on the other hand is running on a remote server and sending the
results back to you. If for some reason your network was blocking data from
yahoo I'd expect Wakari to work and Spyder to not.

You could also try looking at what the http status code is that is being
returned. It not being a "200" is rather vague (see pandas\io\data.py",
line 185, in _retry_read_url).

Regarding Pandas being imported but not used, that is simply a reference
to the fact that you imported the Pandas module but never refer to it in
the code.

import pandas
#You never have pandas. like pandas.DataFrame (the 2nd import doesn't count)

Just remove the first line. It isn't causing any harm but it looks weird.

import pandas.io.data as web #works fine, you don't need a import pandas before hand


Reply to this email directly or view it on GitHub
#2569 (comment).

@JimHokanson
Copy link

If you use a browser on the same computer from which you are running Spyder, that should be a good enough check. If the browser works then it is something in the way that the call is being made. I would recommend debugging at the call point and seeing what the actual http response is, not the cleaned up error that pandas is providing.

@israelyk
Copy link
Author

israelyk commented Aug 4, 2015

How exactly I should debug at the call point? I am new to Python.

@Nodd
Copy link
Contributor

Nodd commented Sep 23, 2015

Sorry but this problem has really nothing to do with spyder, so I'm closing the issue.

@Nodd Nodd closed this as completed Sep 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants