引子:
学习Keras框架安装TensorFlow,单独创建了一个虚拟环境,tf 配置好后没想到在安装matplotlib时出了一堆问题。
PS:之前创建的环境均使用python3.7.0,使用
pip install matplotlib
可以轻松安装,然而这次:
主要报错:
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
----------------------------------------
ERROR: Failed building wheel for kiwisolver
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
解决过程
离线安装第三方库
- 下载whl文件
传送门 - 新建文件夹,用英文命名,减少出错机会
- 打开prompt命令行,进入文件夹
pip install wheel
pip install D:\anaconda\envs\matplotlib-2.2.5-cp37-cp37m-win_amd64.whl
- 检测
import matplotlib
matplotlib.__version__
继续报错:
modulenotfounderror: no module named 'kiwisolver'
返回1,用同样的方法安装kiwisolver库
pip3 install kiwisolver-1.3.0-cp37-cp37m-win_amd64.whl
测试,继续报错:
ImportError: DLL load failed: 找不到指定的模块
错误产生的原因是对应模块的文件不完善或者没有对应的模块
卸载重装
成功!!!
最后
提醒一下安装Matplotlib所需的包有:numpy, dateutil, pytz, pyparsing, kiwisolver, cycler, setuptools。其中安装dateutil和cycler还需要提前安装six包。也可通过检查是否缺少库排除问题原因。