AttributeError: module 'yfinance' has no attribute 'download'
AttributeError: module 'yfinance' has no attribute 'download'
我正在尝试将 yfinance 和一些股票导入 pandas 数据框。最初在导入 yfinance 时遇到了重大问题。我使用 pip 安装,但仍然必须手动放入文件才能真正摆脱无模块错误。
到目前为止,这是我的代码:
现在我在尝试下载 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"]
这是错误:
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 installed using pip but still had to manually put in the files to actually get rid of the no module error.
这可能是错误的原因。非常不鼓励手动操作,始终建议使用打包工具进行安装。如果您使用的是 anaconda 环境,请考虑通过 conda
安装并删除您手动放置的文件。
$ conda install -c ranaroussi yfinance
还要确保您满足所有要求
Python >= 2.7, 3.4+,
Pandas (tested to work with >=0.23.1),
Numpy >= 1.11.1,
requests >= 2.14.2
我刚刚遇到了同样的错误,但在删除名为 yahoofinance 的本地文件后,以下代码有效
!pip install yfinance
import yfinance as yf
import pandas as pd
import datetime as dt
我正在尝试将 yfinance 和一些股票导入 pandas 数据框。最初在导入 yfinance 时遇到了重大问题。我使用 pip 安装,但仍然必须手动放入文件才能真正摆脱无模块错误。
到目前为止,这是我的代码:
现在我在尝试下载 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"]
这是错误:
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 installed using pip but still had to manually put in the files to actually get rid of the no module error.
这可能是错误的原因。非常不鼓励手动操作,始终建议使用打包工具进行安装。如果您使用的是 anaconda 环境,请考虑通过 conda
安装并删除您手动放置的文件。
$ conda install -c ranaroussi yfinance
还要确保您满足所有要求
Python >= 2.7, 3.4+, Pandas (tested to work with >=0.23.1), Numpy >= 1.11.1, requests >= 2.14.2
我刚刚遇到了同样的错误,但在删除名为 yahoofinance 的本地文件后,以下代码有效
!pip install yfinance
import yfinance as yf
import pandas as pd
import datetime as dt