股票

ImportError: No module named finance

尝试用python做个股票绘图软件,要用到 finance 库,于是开始导入:

import matplotlib.finance as mpf

结果执行的时候直接报错:

ImportError: No module named finance

开始还没有安装模块,就专门装了个 finance 模块,使用 import finance 导入,错误倒是没有了,但是 finance 中没有想要的函数,根本无法导出股票数据。去查看 matplotlib 的文档说明,在matplotlib2.2.2的API中有这么一段话:

The matplotlib.financempl_toolkits.exceltools and mpl_toolkits.gtktools modules have been removed. matplotlib.finance remains available at https://github.com/matplotlib/mpl_finance.

finance这个模块竟然被删除了!!!并且就是从2.2.2版本开始。

知道了原因,解决方法就简单了,在github中下载源代码,安装:

python setup.py install

可以看到 mpl_finance模块已经安装上了。

 

打赏
原文链接:,转发请注明来源!

发表评论