ModuleNotFoundError: No module named 'mpl_finance'

ModuleNotFoundError: No module named 'mpl_finance'

您好,我正在学习使用 matplotlib.finance 来使用 candlestick.ohlc 的教程。在研究时,我发现该库已被弃用并使用 mlp_finance。我相信我已经通过 运行 命令提示符并输入行 pip install mpl_finance 安装了它。我得到的结果

我尝试重新 运行 脚本,但我仍然收到错误:

     from  mpl_finance   import candlestick_ohlc
    ModuleNotFoundError: No module named 'mpl_finance'

我检查了 python 库路径,但没有看到标有 mlp_finance 的文件夹(我不确定我是否应该看到)。但我确实看到一个标有 mpl_finance-0.10.0-py3.7.egg

的文件

对解决这个问题有什么帮助吗?下载 git 软件包和 运行 命令提示符安装

运行 命令行 pip install git clone https://github.com/matplotlib/mpl_finance.git mpl_finance.git

您需要在 https://github.com/matplotlib/mpl_finance

安装 matplotlib/mpl_finance
git clone https://github.com/matplotlib/mpl_finance.git mpl_finance.git
cd mpl_finance.git
python setup.py install

pip install mlp_finance 将解决问题

我遇到了和你说的一样的错误,但是我按照下面的方法解决了。

首先,安装mpl_finance

pip install https://github.com/matplotlib/mpl_finance/archive/master.zip

二、升级mpl_finance

pip install --upgrade mplfinance

希望这会奏效。

mpl_finance 已弃用,只需将模块安装为 mplfinance

如果您想在 mpl_finance 上学习该教程,您可以安装新的 mplfinance:

pip install --upgrade mplfinance

然后每个教程告诉你导入的地方from mpl_finance把导入改为
from mplfinance.original_flavor,例如:

变化:

from  mpl_finance   import candlestick_ohlc

from mplfinance.original_flavor import candlestick_ohlc

如果您使用 Anaconda - 要使用 conda 安装此软件包 运行: conda 安装-c conda-forge mplfinance