我已經得到類似這樣的錯誤最近:神祕IndexError
IndexError Traceback (most recent call last)
<ipython-input-124-59ca523b1b36> in <module>()
----> 1 first_experiment_comb(model)
c:\python26\26664\lib\site-packages\experiments.py in first_experiment_comb(mod
l)
172 "Number NZ: " + str(modelz[j].NumNZs) +"\n")
173
--> 174 first_experiment(modelz[j], str(j))
175
176
c:\python26\26664\lib\site-packages\experiments.py in first_experiment(model, e
t)
89 plt.close()
90
---> 91 fl.timberFlow(model)
92 plt.savefig(dire + "\\timber_flow" +ext+".pdf", bbox_inches = 0)
93 plt.close()
C:\Python26\26664\lib\site-packages\func_lib.py in timberFlow(model)
304 if not unVars:
305 unVars = varValues(model, 'PIEHTLVOL')
--> 306
307 for i in range(19):
308 swVarVals.append(swVars[i].X)
IndexError: list index out of range
其中跟蹤點,代碼不存在,或者在以往的案例的最後一行已被註釋掉。當我自己運行最後一個函數(在func_lib.py中)時,我從來沒有得到神祕的IndexError,只有當它從experiments.py中調用時。
我在python python 2.6 W64中運行這個。 我一直無法在iPython或Pylab文檔中發現有關此的已知錯誤。
306行怎麼會成爲錯誤的根?
您的代碼與字節碼不同步。正確地重新加載你的代碼。 – 2013-03-14 21:43:13
無論何時編輯包中的文件,我都會看到這一點,但不要重新編譯。也許有更正確的方式來重新加載代碼,但我做的是,刪除'func_lib.pyc',然後重新啓動python並重新導入模塊這是從 – 2013-03-14 21:45:29