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

json.decoder.JSONDecodeError #760

Closed
draew6 opened this issue Jul 9, 2021 · 30 comments
Closed

json.decoder.JSONDecodeError #760

draew6 opened this issue Jul 9, 2021 · 30 comments

Comments

@draew6
Copy link

draew6 commented Jul 9, 2021

Hi, I am using yfinance daily. Thank you very much for support! But today I received on all scripts I am using this error:
Something changed with new version that is causing this?

Traceback (most recent call last):
File "C:/Users/user/Desktop/NOTES/Codes/project/yf.py", line 7, in
prices.append(yf.Ticker(ticker).history(period="1d")["Close"].values[0])
File "C:\Users\user\Desktop\NOTES\Codes\projectI\venv\lib\site-packages\yfinance\base.py", line 157, in history
data = data.json()
File "C:\Users\user\Desktop\NOTES\Codes\project\venv\lib\site-packages\requests\models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json_init_.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@PatrickDionne
Copy link

Getting same issue now on the yf.download() call, but used it successfully this morning. Didn't make any changes to my version today.

@dennistamyf
Copy link

Is experiencing the same problem. Was running my service normally as of last night.

@GuyHersh
Copy link

GuyHersh commented Jul 9, 2021

Also same issue, was working fine about an hour ago. I was on an older version of yfinance, same error before and after updating.

@hshi0001
Copy link

hshi0001 commented Jul 9, 2021

Same here, worked well 2 hours ago

@daneasterman
Copy link

Yep same error for me as well when running any of the history commands, for example: msft.history(period="max")
I'm on this version: yfinance==0.1.59
Thanks for your help in advance!

@ywluohao
Copy link

ywluohao commented Jul 9, 2021

same issue, is yahoo finance updating again...sigh

@D1al-T0ne
Copy link

Having the same issue! Tried other versions of yfinance.
Tried pulling historical data with Ticker and Download both come back with same error.

@rubikscube09
Copy link

rubikscube09 commented Jul 9, 2021

Same issue :( - Started about half an hour ago.

@chandakrishabh
Copy link

Also having the same issue!

@shivpalit
Copy link

me too! Getting this error though. With 0.1.59 and 0.1.61

Exception in thread Thread-6:
Traceback (most recent call last):
File "/Users/shivpalit/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/shivpalit/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/multitasking/init.py", line 102, in _run_via_pool
return callee(*args, **kwargs)
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/yfinance/multi.py", line 170, in _download_one_threaded
actions, period, interval, prepost, proxy, rounding)
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/yfinance/multi.py", line 185, in _download_one
rounding=rounding, many=True)
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/yfinance/base.py", line 157, in history
data = data.json()
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/requests/models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/simplejson/init.py", line 518, in loads
return _default_decoder.decode(s)
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/Users/shivpalit/anaconda3/lib/python3.7/site-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

@mw66
Copy link

mw66 commented Jul 9, 2021

dup:

#363
#691

looks like it's Yahoo server side problem.

@torolearning101
Copy link

same same.... can't believe they can't make it more stable.

@hshi0001
Copy link

hshi0001 commented Jul 9, 2021

happened before?

@Quantaria
Copy link

Same issue this morning. Happened mid-day.

@ForeverZyh
Copy link

data = data.json()

data in this line returns something like b'Forbidden'. Agree with @mingwugmail, seems like Yahoo side problem.

@djl0
Copy link

djl0 commented Jul 9, 2021

for me, adding a user agent fixed the problem:

headers = {'User-Agent': 'Firefox'}
data = self.session.get(url=url, headers=headers, params=params, proxies=proxy)

data = self.session.get(url=url, params=params, proxies=proxy)

But I'm not sure what the user-agent should be for a project like this, so I'm hesitant to create a PR for this.

@y11z
Copy link

y11z commented Jul 9, 2021

for me, adding a user agent fixed the problem:

headers = {'User-Agent': 'Firefox'}
data = self.session.get(url=url, headers=headers, params=params, proxies=proxy)

Works for me now:

line: 151
headers = {'User-Agent': 'Firefox'}
data = _requests.get(url=url, headers=headers, params=params, proxies=proxy)

@xy345
Copy link

xy345 commented Jul 9, 2021

for me, adding a user agent fixed the problem:

headers = {'User-Agent': 'Firefox'}
data = self.session.get(url=url, headers=headers, params=params, proxies=proxy)

data = self.session.get(url=url, params=params, proxies=proxy)

But I'm not sure what the user-agent should be for a project like this, so I'm hesitant to create a PR for this.

Worked for me.

@mw66
Copy link

mw66 commented Jul 9, 2021

@y11z

can you also try add threads=False:

df = pdr.get_data_yahoo(symbol, start=start_date, progress=False, threads=False)

@mw66
Copy link

mw66 commented Jul 9, 2021

for me, adding a user agent fixed the problem:

headers = {'User-Agent': 'Firefox'}
data = self.session.get(url=url, headers=headers, params=params, proxies=proxy)

data = self.session.get(url=url, params=params, proxies=proxy)

But I'm not sure what the user-agent should be for a project like this, so I'm hesitant to create a PR for this.

It worked for me as well, on Linux.

@djl0 I think you definitely should create a PR.

@rubikscube09
Copy link

for me, adding a user agent fixed the problem:
headers = {'User-Agent': 'Firefox'}
data = self.session.get(url=url, headers=headers, params=params, proxies=proxy)

data = self.session.get(url=url, params=params, proxies=proxy)

But I'm not sure what the user-agent should be for a project like this, so I'm hesitant to create a PR for this.

Worked for me.

What's the best way to edit the package and implement these changes locally? Would like to try it myself.

@ranaroussi
Copy link
Owner

Fixed with 0.1.62.

Please upgrade using pip install -U yfinance

@lfelipecid
Copy link

headers = {'User-Agent': 'Firefox'}

Worked for me!

@JiaxinLIU0998
Copy link

The same issue

Fixed with 0.1.62.

Please upgrade using pip install -U yfinance

It seems that upgrading does not work for me

@ranaroussi
Copy link
Owner

@JiaxinLIU0998 try:
pip install yfinance -U--no-cache-dir

@goldmonkey21
Copy link

goldmonkey21 commented Jul 9, 2021

Fixed it by installing from git:

pip uninstall yfinance
pip install git+https://github.com/ranaroussi/yfinance.git#egg=yfinance

Works!

@shivpalit
Copy link

Anyone know how to fix this issue on Heroku? What should be added to the requirements file?

@ranaroussi
Copy link
Owner

See issue #764

@jalfgit
Copy link

jalfgit commented Jul 11, 2021

i noticed the fix with the upgrade. anyone seeing adj close column coming through?

@NabanCodes
Copy link

pip install -U yfinance worked for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests