473,325 Members | 2,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 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, 613 views)
Jul 30 '10 #1
2 4364
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

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

Similar topics

8
by: sam | last post by:
hey everybody, this is my first time posting here. i'm pretty new to python and programming in general (as you'll soon work out for yourselves...) i'm trying to code a version of a selection...
35
by: erikwickstrom | last post by:
Hi all, I'm sorry about the newbie question, but I've been searching all afternoon and can't find the answer! I'm trying to get this bit of code to work without triggering the IndexError. ...
7
by: python101 | last post by:
My code s= for k in range(len(s)): st=s.count(s) if st>=2: print s.pop(s.index(s)) Traceback (most recent call last):
2
by: Georgy Panterov | last post by:
I am a relatively new python user. I am writing an economic simulation of acard-game. The simulation runs fine for a few iteration but then it gives an error of "list index out of range." The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.