•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 332,655 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,353 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 399 | Replies: 14
![]() |
•
•
Join Date: Aug 2007
Posts: 25
Reputation:
Rep Power: 1
Solved Threads: 0
Hello everyone! I haven't programmed in quite a while and now that I'm getting back into the programming environment for my robotics project again, I'm a little stumped on something:
I'm getting this error message for an exception raised in my VAST python script for my robot. It goes like this:
What stumps me is when I go to line 456, I only see this:
I went back to Health2, but didn't see anything on DateTime_GetNumberOfDaysinYear, there. I even did a find for the phrase in my scripts, but it says it can't find it. I brushed up on my python books, but can't isolate the problem.
If someone could give me any help with this, I'd be obliged. Thanks in advance.
I'm getting this error message for an exception raised in my VAST python script for my robot. It goes like this:
•
•
•
•
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Users\Loren\Desktop\My Robots\Nina Verbal Raw Input.py", line 12, in <module>
from wxPython.wx import *
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wxPython\__init__.py", line 15, in <module>
import _wx
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wxPython\_wx.py", line 8, in <module>
from _misc import *
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wxPython\_misc.py", line 456, in <module>
wxDateTime_GetNumberOfDaysinYear = wx._misc.DateTime_GetNumberOfDaysinYear
AttributeError: 'module' object has no attribute 'DateTime_GetNumberOfDaysinYear'
What stumps me is when I go to line 456, I only see this:
•
•
•
•
"I'll get over it" : "speaker.Speak(random.choice(Health2))",
I went back to Health2, but didn't see anything on DateTime_GetNumberOfDaysinYear, there. I even did a find for the phrase in my scripts, but it says it can't find it. I brushed up on my python books, but can't isolate the problem.
If someone could give me any help with this, I'd be obliged. Thanks in advance.
•
•
Join Date: Jul 2006
Posts: 516
Reputation:
Rep Power: 3
Solved Threads: 61
My money's on a bug in speaker.Speak() OR on an improperly installed wxPython module. Here's why:
Your line chooses a random item from Health2, which is presumed to be a list.
If Health2 is not a list, then random.choice throws a TypeError, which is not your issue.
Further, random.choice() is a well-tested function that couldn't possibly throw the error you're getting. So ... that leaves speaker.Speak() as the source of the error.
Next task: identify the class of "speaker", and check out the code for its Speak() method.
It looks like from the first line of your Traceback that speaker.Speak() tries to import wxPython and do something fancy from there.
Here's how to test for a problem with your wxPython install:
From the command line of IDLE:
If you get the right result, then the bug's in Speak(). If not, then you should (re?)install wx.
Jeff
Your line chooses a random item from Health2, which is presumed to be a list.
If Health2 is not a list, then random.choice throws a TypeError, which is not your issue.
Further, random.choice() is a well-tested function that couldn't possibly throw the error you're getting. So ... that leaves speaker.Speak() as the source of the error.
Next task: identify the class of "speaker", and check out the code for its Speak() method.
It looks like from the first line of your Traceback that speaker.Speak() tries to import wxPython and do something fancy from there.
Here's how to test for a problem with your wxPython install:
From the command line of IDLE:
Python Syntax (Toggle Plain Text)
>>> import wx >>> e = wx.DateTime() >>> e.GetNumberOfDaysInYear(2008) 366
If you get the right result, then the bug's in Speak(). If not, then you should (re?)install wx.
Jeff
•
•
Join Date: Aug 2007
Posts: 25
Reputation:
Rep Power: 1
Solved Threads: 0
Hello again, Jeff!
I test the wxPython install like you said and got the result as you indicated, so its no wxPython.
I think I've isolated the problem to somewhere much earlier in my program:
I tried typing this in the command prompt and it gave back this result:
If I understand correctly, the package I just installed isn't good anymore, so I need to switch to the "wx" package? Where can I find that?
I test the wxPython install like you said and got the result as you indicated, so its no wxPython.
I think I've isolated the problem to somewhere much earlier in my program:
•
•
•
•
from wxPython.wx import *
I tried typing this in the command prompt and it gave back this result:
•
•
•
•
from wxPython.wx import *
__main__:1: DeprecationWarning: The wxPython compatibility package is no longer automatically generated or actively maintained. Please switch to the wx package as soon as possible.
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wxPython\__init__.py", line 15, in <module>
import _wx
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wxPython\_wx.py", line 8, in <module>
from _misc import *
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wxPython\_misc.py", line 456, in <module>
wxDateTime_GetNumberOfDaysinYear = wx._misc.DateTime_GetNumberOfDaysinYear
AttributeError: 'module' object has no attribute 'DateTime_GetNumberOfDaysinYear'
If I understand correctly, the package I just installed isn't good anymore, so I need to switch to the "wx" package? Where can I find that?
•
•
Join Date: Aug 2007
Posts: 25
Reputation:
Rep Power: 1
Solved Threads: 0
Okay, I think I found the answer to that. All I had to do was change, say wxbitmap to wx.bitmap, in my script.
But now I'm getting something else. When I try running the script, I get this error message:
I first thought this had something to do with the SAPI SDK 5.1 not being install on my New computer (my old laptop suffered a spill, so that's why I'm having trouble getting this script to work again on my new one). But apparently, after reinstalling it, I get the same message. Could it be that the python win32 extention isn't installed on my laptop? Because I thought I installed it...
But now I'm getting something else. When I try running the script, I get this error message:
•
•
•
•
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Users\Loren\Desktop\My Robots\Nina Verbal Raw Input.py", line 75, in <module>
class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):
TypeError: Error when calling the metaclass bases
cannot create 'NoneType' instances
I first thought this had something to do with the SAPI SDK 5.1 not being install on my New computer (my old laptop suffered a spill, so that's why I'm having trouble getting this script to work again on my new one). But apparently, after reinstalling it, I get the same message. Could it be that the python win32 extention isn't installed on my laptop? Because I thought I installed it...
•
•
Join Date: Aug 2007
Posts: 25
Reputation:
Rep Power: 1
Solved Threads: 0
I believe the bug is indeed, in speaker.Speak(). I tried retyping the script in the comman line to see step by step what was working and what was going through. The moment I finished typing in I got that
I only have a rough idea of whats happening in the computer as far as coding is concerned, so I'm not sure how to fix this problem...
•
•
•
•
class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):
def OnRecognition(self, StreamNumber, StreamPosition, RecognitionType, Result):
newResult = win32com.client.Dispatch(Result)
•
•
•
•
TypeError: Error when calling the metaclass bases
I only have a rough idea of whats happening in the computer as far as coding is concerned, so I'm not sure how to fix this problem...
•
•
Join Date: Jul 2006
Posts: 516
Reputation:
Rep Power: 3
Solved Threads: 61
And I have no knowledge at all of the Voice Recognition module... :lol:
This error is saying something interesting:
Apparently, it is defining a class that inherits from the result of the call to
win32com.client.getevents("SAPI.SpSharedRecoContext")
I've not heard of dynamic inheritance before, but it makes sense that Python could do it!
I was able to reproduce the bug like this:
So apparently, win32com.client.getevents("SAPI.SpSharedRecoContext") is returning None when it ought to return some class name.
Can you find anything out about that?
Jeff
This error is saying something interesting:
•
•
•
•
class ContextEvents(win32com.client.getevents("SAPI.SpSharedRecoContext")):
TypeError: Error when calling the metaclass bases
cannot create 'NoneType' instances
Apparently, it is defining a class that inherits from the result of the call to
win32com.client.getevents("SAPI.SpSharedRecoContext")
I've not heard of dynamic inheritance before, but it makes sense that Python could do it!
I was able to reproduce the bug like this:
Python Syntax (Toggle Plain Text)
class MyClass(eval(raw_input("Enter a Class: "))): pass >>> Enter a Class: object >>> m = MyClass() >>> print m <__main__.MyClass object at 0x00BFB250> --- >>> Enter a Class: str >>> m = MyClass() >>> print m >>> m '' >>> --- >>> Enter a Class: None >>> m = MyClass() Traceback (most recent call last): File "C:/Python25/dyninherit.py", line 1, in <module> class MyClass(eval(raw_input("Enter a Class"))): TypeError: Error when calling the metaclass bases cannot create 'NoneType' instances
So apparently, win32com.client.getevents("SAPI.SpSharedRecoContext") is returning None when it ought to return some class name.
Can you find anything out about that?
Jeff
•
•
Join Date: Aug 2007
Posts: 25
Reputation:
Rep Power: 1
Solved Threads: 0
Hi Jeff. I think my problem was I hadn't used the MakePy Windows speech Object Library on it, because it got rid of that error. Now I'm getting something else, much farther down the script:
From what I understand, 'true' is a type of switch or property. It should work in any python script without importing or fancy defining or anything like that.
Here's the chunk of code that seems to be affected:
Its part of a class called "MyApp(wx.App):" which is extremely vast with the lists of phrases my robot responds to.
Any ideas? I think we're both sort of exploring this speech recognition python territory. I'll keep investigating on my own as well.
•
•
•
•
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Users\Loren\Desktop\My Robots\Nina Verbal Raw Input.py", line 674, in <module>
app = MyApp(0)
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7836, in __init__
self._BootstrapApp()
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7433, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "C:\Users\Loren\Desktop\My Robots\Nina Verbal Raw Input.py", line 551, in OnInit
self.InitSpeech()
File "C:\Users\Loren\Desktop\My Robots\Nina Verbal Raw Input.py", line 527, in InitSpeech
self.turnedOn = true
NameError: global name 'true' is not defined
From what I understand, 'true' is a type of switch or property. It should work in any python script without importing or fancy defining or anything like that.
Here's the chunk of code that seems to be affected:
•
•
•
•
def InitSpeech(self):
listener = win32com.client.Dispatch("SAPI.SpSharedRecognizer")
self.context = listener.CreateRecoContext()
self.grammar = self.context.CreateGrammar()
self.grammar.DictationSetState(0)
self.ListItemsRule = self.grammar.Rules.Add("ListItemsRule", constants.SRATopLevel + constants.SRADynamic, 0)
events = ContextEvents(self.context)
self.turnedOn = true
self.SetWords()
Its part of a class called "MyApp(wx.App):" which is extremely vast with the lists of phrases my robot responds to.
Any ideas? I think we're both sort of exploring this speech recognition python territory. I'll keep investigating on my own as well.
•
•
Join Date: Aug 2007
Posts: 25
Reputation:
Rep Power: 1
Solved Threads: 0
Oh, right. Thanks, Jeff! That solved that problem.
Now when I run the script, the windows speed recognition activates! Theres another exception that comes up though, but since the windows speech recognition comes up just before the exception, I know we're getting close.
Here's whats coming up now:
Here's the chunk of code that seems to be affected.
Once again, I'm not sure how that works. Isn't NULL an expression you can use without defining it? I think that might be typed incorrectly, like with 'true,' but I'm not sure how to fix it. You know what's going on? I'll hit the books in the meantime.
Loren
Now when I run the script, the windows speed recognition activates! Theres another exception that comes up though, but since the windows speech recognition comes up just before the exception, I know we're getting close.
Here's whats coming up now:
•
•
•
•
Setting words - turned on
Traceback (most recent call last):
File "C:\Python25\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
exec codeObject in __main__.__dict__
File "C:\Users\Loren\Desktop\My Robots\Nina Verbal Raw Input.py", line 674, in <module>
app = MyApp(0)
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7836, in __init__
self._BootstrapApp()
File "C:\Python25\lib\site-packages\wx-2.8-msw-unicode\wx\_core.py", line 7433, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "C:\Users\Loren\Desktop\My Robots\Nina Verbal Raw Input.py", line 553, in OnInit
self.frame = wx.Frame(NULL, -1, "Speech tester", wx.Point(10,10), wx.Size(770,300))
NameError: global name 'NULL' is not defined
Here's the chunk of code that seems to be affected.
•
•
•
•
def OnInit(self):
self.setItems()
self.InitSpeech()
self.frame = wx.Frame(NULL, -1, "Speech tester", wx.Point(10,10), wx.Size(770,300))
self.listBox = wx.ListBox(self.frame, self.LISTBOX_ID, wx.Point(10, 10), wx.Size(120, 200),
self.items.keys(), wx.LB_SINGLE)
self.addButton = wx.Button(self.frame, self.ADD_BUTTON_ID, "Add", wx.Point(10,230), wx.Size(50, 30))
self.deleteButton = wx.Button(self.frame, self.DELETE_BUTTON_ID, "Delete", wx.Point(80, 230), wx.Size(50, 30))
self.editor = wx.TextCtrl(self.frame, self.EDITOR_ID, "", wx.Point(140,10), wx.Size(600,200),
style=wx.SUNKEN_BORDER+wx.TE_MULTILINE+wx.TE_PROCESS_TAB)
self.testButton = wx.Button(self.frame, self.TEST_BUTTON_ID, "Test", wx.Point(140, 230), wx.Size(50, 30))
self.turnonButton = wx.Button(self.frame, self.TURNON_BUTTON_ID, "On", wx.Point(210, 230), wx.Size(50, 30))
self.turnoffButton = wx.Button(self.frame, self.TURNOFF_BUTTON_ID, "Off", wx.Point(280, 230), wx.Size(50, 30))
self.SetUpTaskbar()
EVT_LISTBOX(self, self.LISTBOX_ID, self.OnListBoxSelect)
EVT_BUTTON(self, self.ADD_BUTTON_ID, self.OnAddClick)
EVT_BUTTON(self, self.DELETE_BUTTON_ID, self.OnDeleteClick)
EVT_BUTTON(self, self.TEST_BUTTON_ID, self.OnTestClick)
EVT_BUTTON(self, self.TURNON_BUTTON_ID, self.OnTurnOnClick)
EVT_BUTTON(self, self.TURNOFF_BUTTON_ID, self.OnTurnOffClick)
EVT_TEXT(self, self.EDITOR_ID, self.OnTextEntered)
EVT_ICONIZE(self.frame, self.OnIconize)
EVT_CLOSE(self.frame, self.OnExitFrame)
self.listBox.SetSelection(0)
self.displayTextBox()
self.frame.Show(True)
self.SetTopWindow(self.frame)
return True
Once again, I'm not sure how that works. Isn't NULL an expression you can use without defining it? I think that might be typed incorrectly, like with 'true,' but I'm not sure how to fix it. You know what's going on? I'll hit the books in the meantime.
Loren
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
Similar Threads
- Exception in thread "main" java.lang.NoClassDefFoundError: Invaders Error (Java)
- I hava trouble with Microsoft Access database, Pls help me. (Java)
- Noob : Input Stream Trouble (Java)
- re: Trouble with GUI (Java)
- Text printing is giving me trouble (C#)
- Help!!!!!! General Protection Exception (C++)
- Hardware/Software double trouble (Troubleshooting Dead Machines)
- General Protection Exception Error Please Help! (C++)
Other Threads in the Python Forum
- Previous Thread: Finding top 10 values in csv file
- Next Thread: Special sort a list


)
Linear Mode