我写这段代码:
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"))我已经安装了YahooFinance1.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“并得到了这个信息
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:请帮我解决这个错误。
发布于 2021-05-16 16:53:31
它应该像你使用它的方式一样工作。可能的问题可能是环境变化。通过查看pip中yahoofinancials库的位置,我认为您在虚拟环境中安装了它,也许您的其他库也在您的全球环境中。检查是否已激活虚拟环境或尝试在全球环境中安装yahoofinancials。
发布于 2021-05-16 17:12:13
我安装了上面的所有内容(包括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"))萨缪尔
发布于 2022-06-11 00:47:50
安装- yahoofinancials运行在Python2.7、3.3、3.4、3.5、3.6和3.7上。
详情见- https://pypi.org/project/yahoofinancials/
包依赖于beautifulsoup4和pytz才能工作。
使用pip安装:
Linux/Mac
$ pip安装yahoofinancials
(如果python在cmd中不适用于您,请尝试使用“仅py”运行以下命令):
python -m pip安装yahoofinancials
使用github (Mac/Linux)安装:
$ git克隆https://github.com/JECSand/yahoofinancials.git
$
$ python setup.py安装
https://stackoverflow.com/questions/67559043
复制相似问题