背景
今日我的Python心路历程是 初探python调试总结之import matplotlib.finance库问题ImportError: No module named finance)
分析
事后得知matplotlib.finance库经过几次迭代,兼容性也是我们要考虑的方面,根据本机python环境版本做好对应包安装就好,本文重点将安装过程中的问题处理。
修改前代码:
from matplotlib.finance import candlestick_ohlc
编译出错 from matplotlib.finance import candlestick_ohlc ImportError: No module named finance
方案
获悉从matplotlib 2.2.0开始,matplotlib已经不包含finance模块。可以使用mpl_finance进行替代。
mpl_finance库需要手动安装.通过以前的界面方法load库文件失败,故此直接在终端模式下命令行pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade mpl_finance
解决了这个问题。当时现象如下图所示:
import requests时失败的处理方式类似。
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'. ERROR: Could not find a version that satisfies the requirement requests ERROR: No matching distribution found for requests