By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,199 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,199 IT Pros & Developers. It's quick & easy.

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

P: 5
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, 550 views)
Jul 30 '10 #1
Share this Question
Share on Google+
2 Replies


bvdet
Expert Mod 2.5K+
P: 2,851
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

nakul27
P: 1
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.