5

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?

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197

3 Answers3

5

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
EoinS
  • 5,405
  • 1
  • 19
  • 32
1

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"

DirtFarmer
  • 17
  • 3
0

This worked for me:

pip uninstall yfinance
pip uninstall pandas-datareader
pip install yfinance --upgrade --no-cache-dir
pip install pandas-datareader