Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yfinance not working - receiving json.decoder.JSONDecodeError

I am scraping stock market data from yfinance. My code worked perfectly during the last weeks. For some reason, now I am receiving the following error:

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

when executing:

import yfinance as yf
tsla_df = yf.download('TSLA', start='2020-01-01', end='2021-01-01', progress=False)

I have read about this error on Stack Overflow, but no one had an appropriate solution to fix the problem. I am wondering because this simple code worked well days ago. So maybe there is a general problem with the yfinance API at the moment? Can anyone confirm or has a solution for this problem?

like image 224
müller mann Avatar asked Jul 09 '21 18:07

müller mann


2 Answers

Issue has been raised with yfinance, you need to upgrade

Follow here

https://github.com/ranaroussi/yfinance/issues/764

from github:

If you're getting an json.decoder.JSONDecodeError related error, please upgrade to yfinance 0.1.62. Upgrade using:

$ pip install yfinance -U--no-cache-dir

Full conversation here : https://github.com/ranaroussi/yfinance/issues/760

I couldn't get the fix to work but this comment worked for me https://github.com/ranaroussi/yfinance/issues/760#issuecomment-877379498

pip uninstall yfinance
pip install git+https://github.com/ranaroussi/yfinance.git#egg=yfinance
like image 177
EoinS Avatar answered Oct 11 '22 10:10

EoinS


Checked out https://github.com/ranaroussi/yfinance/issues/764 and his suggestion didn't work for me but I got it done with

"pip install --upgrade yfinance"

like image 1
DirtFarmer Avatar answered Oct 11 '22 10:10

DirtFarmer