yfinance
yfinance copied to clipboard
problem in using without console on windows, AttributeError: 'NoneType' object has no attribute 'flush'
I am using python 3.11.5 (windows 11) When i am trying to running my script without console, which is downloading data through yfinance, it is not working. when i am running with console, then only script is proper functioning. following is error:
Traceback (most recent call last):
File "E:\share market\yahu finance\instent running\automated_analysis\5_EMA\second_approach\run_ema.pyw", line 96, in third
data = yf.download(tickers=f'{company}', period='60d', interval='5m', group_by='ticker', auto_adjust=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abhishek\AppData\Roaming\Python\Python311\site-packages\yfinance\utils.py", line 103, in wrapper
result = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\abhishek\AppData\Roaming\Python\Python311\site-packages\yfinance\multi.py", line 177, in download
shared._PROGRESS_BAR.completed()
File "C:\Users\abhishek\AppData\Roaming\Python\Python311\site-packages\yfinance\utils.py", line 862, in completed
_sys.stderr.flush()
^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'flush'
any solution?
same issue, python 3.9
I have a solution y can try it,
" use .history() instead of .download() " code here:
def yfinance():
import datetime
from dateutil.relativedelta import relativedelta
import yfinance as yf
date = datetime.datetime.now().date()
end_date = date
start_date = date + relativedelta(months= -63)
msft = yf.Ticker("MSFT")
# get historical market data
hist = msft.history(start=start_date, end=end_date, interval="1mo")
hist.to_excel("ms.xlsx", index=None)
yfinance()
the detail ref url here https://pypi.org/project/yfinance/
god bless y