0

The code is so simple I don't know how the error can be solved. All the packages has been updated.

import datetime as dt
import yfinance as yf

ticker = 'MSFT'
start_date = dt.datetime(2020,1,1)

data = yf.download(ticker, start_date)

And the error is in .json, I don't have any ideas how this can be solved.

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/multitasking/__init__.py", line 102, in _run_via_pool
    return callee(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/yfinance/multi.py", line 169, in _download_one_threaded
    data = _download_one(ticker, start, end, auto_adjust, back_adjust,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/yfinance/multi.py", line 181, in _download_one
    return Ticker(ticker).history(period=period, interval=interval,
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/yfinance/base.py", line 157, in history
    data = data.json()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/requests/models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/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)
phd
  • 82,685
  • 13
  • 120
  • 165
  • 2
    Other Duplicates from today -> [yfinance json.decoder.JSONDecodeError](https://stackoverflow.com/q/68328050/15497888), [The same code that used to work is now returning an exception](https://stackoverflow.com/q/68331693/15497888) it appears upgrading to yfinance==0.1.62 or newer fixes the issue. – Henry Ecker Jul 10 '21 at 22:27
  • 2
    I would remove the `pip`, `pipenv` and `json` tags. It is very likely a __version-issue of _yfinance_ that is caused by a mismatch between this API-facade and the Yahoo-Finance REST API__. That's why the JSON version returned from Yahoo's REST API is other than expected from library. You should state the version of _yfinance_ you are using. – hc_dev Jul 10 '21 at 22:51
  • 2
    I see this problem in forth question today. Probably Yahoo changed web page and now module needed new code. – furas Jul 10 '21 at 23:07
  • Thanks, I was updating wrong the packages – Jaumecomasfez Jul 13 '21 at 21:47

0 Answers0