繁体   English   中英

ModuleNotFoundError: No module named 'yfinance' - Importing Yahoo finance & Financials 到 Python

[英]ModuleNotFoundError: No module named 'yfinance' - Importing Yahoo finance & Financials to Python

我正在使用 Mac OS,并在执行以下操作时收到错误消息:

import pandas as pd
import yfinance as yf
from yahoofinancials import YahooFinancials

ModuleNotFoundError:没有名为“yfinance”的模块

我已经检查过 pip 是否已安装到最新版本并且我已经完成了 pip 列表并且 yfinance 就在那里。

我还检查过:

pip show yfinance
Name: yfinance
Version: 0.1.70
Summary: Download market data from Yahoo! Finance API
Home-page: https://github.com/ranaroussi/yfinance
Author: Ran Aroussi
Author-email: ran@aroussi.com
License: Apache
Location: /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages
Requires: lxml, multitasking, numpy, pandas, requests
Required-by: 
MacBook-Air:~ User$ 

这样就安装好了,路径是Python3最新的python。

我真的很感激任何建议!

谢谢

[编辑]

我从默认的 Spyder 环境运行 Spyder。

把这个放在开头

!pip install yfinance

使用 pip 安装 yfinance package:

pip install -i https://pypi.anaconda.org/ranaroussi/simple finance

使用 conda 安装 yfinance package:

conda install -c ranaroussi yfinance

我在 Linux 上有同样的错误。通过以下代码强制重新安装 package 来纠正。

python -m pip install -U --force-reinstall yfinance 

=

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM