Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'yfinance' has no attribute 'download'

I'm trying to import yfinance and some stocks into pandas dataframe. Initially had major issues importing yfinance. I installed using pip but still had to manually put in the files to actually get rid of the no module error.

This is my code so far:

Now I'm getting attribute error when trying to download yfinance.

import pandas as pd
import datetime as dt
import yfinance as yf
# import fix_yahoo_finance as yf

stocks = ["AMZN", "MSFT", "INTC", "GOOG", "INFY.NS", "3988.HK"]
start = dt.datetime.today()- dt.timedelta(30)
end = dt.datetime.today()
cl_price = pd.DataFrame()

for ticker in stocks:
    cl_price[ticker] = yf.download(ticker,start,end)["Adj Close"]

and this is the error:

AttributeError                            Traceback (most recent call last)
<ipython-input-51-3347ed0c7f2b> in <module>
     10 
     11 for ticker in stocks:
---> 12     cl_price[ticker] = yf.download(ticker,start,end)["Adj Close"]

AttributeError: module 'yfinance' has no attribute 'download'

I tried the suggestion from AttributeError: module 'yahoo_finance' has no attribute 'download' but its still not working

Any solutions appreciated

like image 449
HJ10 Avatar asked Oct 18 '25 19:10

HJ10


1 Answers

I just been having the same error but the following code worked after deleting a local file named yahoofinance

!pip install yfinance
import yfinance as yf
import pandas as pd
import datetime as dt
like image 57
S. K. Avatar answered Oct 21 '25 08:10

S. K.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!