Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

433
Visualizações
JSON Decode Error with yFinance [JSONDecodeError: Expecting value: line 1 column 1 (char 0)]

I have been using yfinance for the last several weeks to pull historical data on a number of stocks. I normally run the program at the end of each week to store data for that week, but this problem error just randomly starting occurring this past week. Below is a simple example of calling for historical price data for MMM. However, the same error occurs for option contract methods.

import yfinance as yf
mmm = yf.Ticker('MMM')
mmm.history()

Error Stack:

JSONDecodeError                           Traceback (most recent call last)
<ipython-input-6-68e978705cca> in <module>
      1 mmm = yf.Ticker('MMM')
----> 2 mmm.history()

~/opt/anaconda3/lib/python3.8/site-packages/yfinance/base.py in history(self, period, interval, start, end, prepost, actions, auto_adjust, back_adjust, proxy, rounding, tz, **kwargs)
    155                                "Our engineers are working quickly to resolve "
    156                                "the issue. Thank you for your patience.")
--> 157         data = data.json()
    158 
    159         # Work with errors

~/opt/anaconda3/lib/python3.8/site-packages/requests/models.py in json(self, **kwargs)
    896                     # used.
    897                     pass
--> 898         return complexjson.loads(self.text, **kwargs)
    899 
    900     @property

~/opt/anaconda3/lib/python3.8/json/__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    355             parse_int is None and parse_float is None and
    356             parse_constant is None and object_pairs_hook is None and not kw):
--> 357         return _default_decoder.decode(s)
    358     if cls is None:
    359         cls = JSONDecoder

~/opt/anaconda3/lib/python3.8/json/decoder.py in decode(self, s, _w)
    335 
    336         """
--> 337         obj, end = self.raw_decode(s, idx=_w(s, 0).end())
    338         end = _w(s, end).end()
    339         if end != len(s):

~/opt/anaconda3/lib/python3.8/json/decoder.py in raw_decode(self, s, idx)
    353             obj, end = self.scan_once(s, idx)
    354         except StopIteration as err:
--> 355             raise JSONDecodeError("Expecting value", s, err.value) from None
    356         return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)
over 4 years ago · Santiago Trujillo
6 Respostas
Responde à pergunta

0

Im new to Stack Overflow so I couldn't upvote but I was having a similar issue. After seeing the answer @Barmar left I went to the yfinance github and the author recommends using pip install yfinance --upgrade --no-cache-dir to resolve any current issues. Worked for me, I hope it works for you since we seem to have similar issues :]

over 4 years ago · Santiago Trujillo Relatório

0

tl;dr Sometime in July 2021, Yahoo Finance made some change to their code, and the Python libraries that 'talk' to it now have to be updated, so you probably need to update your module.

Here's my story:

I use a slightly different package called yahoo_fin. I also have been getting this error, and it all started on July 9, 2021. Coincidentally, I saw on yahoo_fin's documentation website here that there were some changes made quite recently on Yahoo Finance, and that may be what's impacting all these libraries that seem to pull their stock data from Yahoo Finance.

Update: July 9th, 2021 yahoo_fin 0.8.9.1 is the latest version of yahoo_fin. This includes a second collection of patches due to recent changes in Yahoo Finance’s website, which were affecting get_data, get_live_price, and several other methods. Please update to 0.8.9.1 if you are using an older version. Additionally, there are two new functions, get_company_info and get_company_officers, for scraping company-related data.

Update: July 2021 yahoo_fin 0.8.9 was released in July 2021. This release includes a patch fixing get request issues due to recent changes on Yahoo Finance. These updates affect several functions, including scraping options data, get_quote_table,

In the end, I had to run pip install yahoo_fin --update, and that resolved it.

over 4 years ago · Santiago Trujillo Relatório

0

Try this:

pip uninstall yfinance
pip uninstall pandas-datareader
pip install yfinance --upgrade --no-cache-dir
pip install pandas-datareader
over 4 years ago · Santiago Trujillo Relatório

0

If Anyone Still facing problem with jsonDecoder error. Try deleting yfin from venv of pycharm folder. Somehow my system was not upgrading yfin in venv of pycharm. I had to manually delete yfin folder and upgrad yfin. Its now working for me. Thanks

over 4 years ago · Santiago Trujillo Relatório

0

I have given up on yfinance and started using yahoo_fin. It's as simple to use but better due to it's upkeep.

from yahoo_fin.stock_info import *
df = get_data('BYND', start_date='2020-08-14')
over 4 years ago · Santiago Trujillo Relatório

0

I encountered the same when using "from yahoo_fin import stock_info as si".

The problem solved by:

pip install yahoo_fin --upgrade
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda