python-报错和解决方法汇总

python的错误提示非常人性化,通常报错时就会提供解决办法,整理了一下遇到的稍微麻烦一些的:

1.  Matplotlib Deprecation Warning: The finance module has been deprecated in mpl 2.0 and will be removed in mpl 2.2. Please use the module mpl_finance instead.

原因:输入import mpl_finance as finance,程序说没有这个模块。因为新版本mpl 2.2中,finance才会被替换成mpl_finance,目前import matplotlib.finance是不会影响使用的。为了兼容新版本,可以下载mpl_finance这个模块,这样才可以import

解决:

  windows: 命令行输入:pip install https://github.com/matplotlib/mpl_finance/archive/master.zip 

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

2. Python IndexError: list assignment index out of range

原因:通常是因为直接对空的list进行赋值,比如A=[];A[0]=1

解决:A.append(1)

3.

猜你喜欢

转载自www.cnblogs.com/timotong/p/9502483.html