471,066 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Python Using Py2exe (IndexError: list index out of range)

I wrote a program that uses PyQt4, mathplotlib to
generates graphs. I made a executable file using Py2exe.

Everything is working fine, but when I exit from my
program, a window message pops out and tells me to look
at the log file. In the log file, here is what they said

C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 572: UserWarning: Could not find matplotlibrc; using defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 633: UserWarning: could not find rc file; returning defaults
Traceback (most recent call last):
File "Epages.pyc", line 305, in refractorySimulation
IndexError: list index out of range
Traceback (most recent call last):
File "Epages.pyc", line 305, in refractorySimulation
IndexError: list index out of range
Traceback (most recent call last):
File "Epages.pyc", line 305, in refractorySimulation
IndexError: list index out of range
Traceback (most recent call last):
File "Epages.pyc", line 305, in refractorySimulation
IndexError: list index out of range
Traceback (most recent call last):
File "Epages.pyc", line 305, in refractorySimulation
IndexError: list index out of range
Traceback (most recent call last):
File "Epages.pyc", line 277, in thresholdSimulation
IndexError: list index out of range
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 572: UserWarning: Could not find matplotlibrc; using defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 633: UserWarning: could not find rc file; returning defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 572: UserWarning: Could not find matplotlibrc; using defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 633: UserWarning: could not find rc file; returning defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 572: UserWarning: Could not find matplotlibrc; using defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 633: UserWarning: could not find rc file; returning defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 572: UserWarning: Could not find matplotlibrc; using defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 633: UserWarning: could not find rc file; returning defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 572: UserWarning: Could not find matplotlibrc; using defaults
C:\Users\dmckinnon\Desktop\ChrisKim\eSimulator_ori ginal\src\dist\library.zip\matplotlib\__init__.py: 633: UserWarning: could not find rc file; returning defaults


Basically, it is saying there is a "List Index out of range" in my code line 305

What is the problem with my code line 305?
I attached my program below...
The line 305 looks like this
Expand|Select|Wrap|Line Numbers
  1. def refractorySimulation(self):
  2.         delaysteps = [ 10, 12, 14, 16, 18, 20, 25, 30, 35]
  3.         delay2 = delaysteps[self.counter]
  4.         self.counter = self.counter + 1
  5.         self.delay2_spinBox.setValue(delay2)
  6.         self.updateSimulation()
  7.         # This terminates the loop by setting the Qtimer to a single shot at the second last value of 'currentsteps'
  8.         if (self.counter >= (len(delaysteps) - 1)):     
  9.             self.timer.setSingleShot(True)
  10.             localtimer = QtCore.QTimer()    # need this second timer to delay activation of widgets until after final run is finished
  11.             localtimer.singleShot(800, self.activateControlWidgets)
  12.  



So please take a look at it and help me...

Thank you very much in advance....
Attached Files
File Type: txt Epages.txt (16.4 KB, 589 views)
Jul 30 '10 #1
2 4178
bvdet
2,851 Expert Mod 2GB
Apparently this line:
Expand|Select|Wrap|Line Numbers
  1. delay2 = delaysteps[self.counter]
is the problem. self.counter must have been incremented to a number equal to the number of items in delaysteps.

Expand|Select|Wrap|Line Numbers
  1. >>> s = [1,2,3,4,5]
  2. >>> s[5]
  3. Traceback (most recent call last):
  4.   File "<interactive input>", line 1, in ?
  5. IndexError: list index out of range
  6. >>> 
Jul 30 '10 #2
That's correct, problem is with delaysteps, you need to do boundchecking for an array.

IndexError: list index out of range, this error signifies that you are trying to access an element of an list which does not exist or say out or list range.
Aug 21 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.