Python 没有名为 'yahoofinancials' 的模块

Python no module named 'yahoofinancials'

我写这段代码:

import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from yahoofinancials import YahooFinancials


yahoo_finance = YahooFinancials(str(stock))
stats=(yahoo_finance.get_historical_price_data("2010-01-01", "2021-04-30", "daily"))

我已经安装了 yahoo-finance1.4.0、yahoofinancials1.6、yfinance0.1.59 并尝试这个

依次输入以下四行,每行执行一次:

pip install yahoo-finance
 
git clone git://github.com/lukaszbanasiak/yahoo-finance.git
 
cd yahoo-finance
 
python setup.py install

但仍然显示错误“没有名为 'yahoofinancials' 的模块”

我已经检查了这个代码“>pip show yahoofinancials”并获得了这个信息

Name: yahoofinancials
Version: 1.6
Summary: A powerful financial data module used for pulling both fundamental and technical data from Yahoo Finance
Home-page: https://github.com/JECSand/yahoofinancials
Author: Connor Sanders
Author-email: connor@exceleri.com
License: MIT
Location: c:\users\user\stockspredct\lib\site-packages
Requires: beautifulsoup4, pytz
Required-by:

请帮我解决这个错误

它应该按照您的使用方式工作。可能的问题可能是环境变化。通过查看 pip 中 yahoofinancials 库的位置,我认为你将它安装在虚拟环境中,也许你的其他库在你的全局环境中。检查您是否激活了虚拟环境或尝试在全局环境中安装yahoofinancials。

我按照上面的方法安装了所有东西(包括 beautifulsoup4 和 pytz)并得到了同样的错误信息。

我稍微修改了代码,但没有收到任何错误消息。

import pandas as pd
import numpy as np
from sklearn.linear_model import LinearRegression
from yahoofinancials import YahooFinancials

stock = ['AAPL']
yahoo_finance = YahooFinancials(stock)
stats = (yahoo_finance.get_historical_price_data("2010-01-01", "2021-04-30", "daily"))

问候塞缪尔