我正在用python玩Dragonfly lib。我正在使用Windows7 + python2.6。但是,当我尝试运行演示代码时(这是Dragonfly的示例)

from dragonfly.all import Grammar, CompoundRule

# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
    spec = "do something computer"                  # Spoken form of command.
    def _process_recognition(self, node, extras):   # Callback when command is spoken.
        print "Voice command spoken."

# Create a grammar which contains and loads the command rule.
grammar = Grammar("example grammar")                # Create a grammar to contain the command rule.
grammar.add_rule(ExampleRule())                     # Add the command rule to the grammar.
grammar.load()                                      # Load the grammar.


我收到以下错误:

Traceback (most recent call last):
  File "test.py", line 2, in <module>
    from dragonfly.all import Grammar, CompoundRule
ImportError: No module named all


我该如何解决?

最佳答案

摆脱.all。这个例子似乎已经过时了。它看起来应该像这样:

from dragonfly import Grammar, CompoundRule

关于python - 在Windows7和python2.6上使用python蜻蜓的问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/32668599/

10-12 22:48