此文只是记录本人在运行吴老师机器学习作业时,我用的Python包和作业源码不匹配,导致作业中一些老版本的功能在新版本中去掉了就报错。我在网上搜集了一下解决办法,汇总了方便下次遇到又得搜好久,所以算不得原创,如果以后遇到新问题了再更新一下加进去,也希望对类似问题有所帮助。
AttributeError: module ‘matplotlib.cbook‘ has no attribute ‘iterable‘
也出现过AttributeError:Traceback (most recent call last),导致梯度下降过程在等高线上无法绘制
![](https://i-blog.csdnimg.cn/blog_migrate/0de5ac111721c8cf4d938f248af2ebd5.png)
原因: matplotlib版本太高了,或太低。我一开始试了2.0.0,后面又upgrade,结果都有问题。
解决: 最终是将matplotlib 版本切换至3.1.0
![](https://i-blog.csdnimg.cn/blog_migrate/41ff1a1ea51268fbecdbf64b0b3dcea2.png)
AttributeError:Traceback (most recent call last) OverflowError: Python int too large to convert to C long
![](https://i-blog.csdnimg.cn/blog_migrate/7a1039af87d1f1d037ee74f7e871faad.png)
原因: 字符过长溢出,导致数组报错
解决:
![](https://i-blog.csdnimg.cn/blog_migrate/d7e2d0deef5797c3250f27fc00c5abd0.png)
KeyError: '3d'
原因: 源代码问题,少导入了工具包。
解决: 开头加调用
from mpl_toolkits.mplot3d import Axes3D
![](https://i-blog.csdnimg.cn/blog_migrate/e0b5058bab628b8c2a8933fcbee1da1b.png)