我正在运行 2.7,并且正在使用 pyinstaller。我的目标是输出一个 exe 并让它运行我的其他类文件。我还使用https://code.google.com/p/dragonfly/作为语音识别框架。我在 Dragonfly->examples->text.py 下的示例方向创建了另一个文件。如果我用我的 IDE 运行https://code.google.com/p/dragonfly/source/browse/trunk/dragonfly/examples/dragonfly-main.py?spec=svn79&r=79我可以说语音命令,它会理解我创建的以下文件和蜻蜓示例中的其他示例文件。
from dragonfly.all import Grammar, CompoundRule, Text, Dictation
import sys
sys.path.append('action.py')
import action
# Voice command rule combining spoken form and recognition processing.
class ExampleRule(CompoundRule):
print "This works"
spec = "do something computer" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print "Voice command spoken."
class AnotherRule(CompoundRule):
spec = "Hi there" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print "Well, hello"
# 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.add_rule(AnotherRule()) # Add the command rule to the grammar.
grammar.load()
# Load the grammar.
我在控制台中注意到它会输出
UNKNOWN: valid paths: ['C:\\Users\\user\\workspace\\dragonfly\\dragonfly-0.6.5\\dragonfly\\examples\\action.py',etc..etc...
在我使用 pyinstaller 之后,该行的输出是
UNKNOWN: valid paths: []
所以它没有加载示例,因为它找不到它们。我如何告诉 pyinstaller 在创建 exe 时也加载示例文件?如果它确实加载了文件,我如何确保我的 exe 知道文件在哪里?
我为 pyinstaller 运行的命令
C:\Python27\pyinstaller-2.0>python pyinstaller.py -p-paths="C:\Users\user\worksp
ace\dragonfly\dragonfly-0.6.5\dragonfly\examples\test.py" "C:\Users\user\workspa
ce\dragonfly\dragonfly-0.6.5\dragonfly\examples\dragonfly-main.py"