我正在运行2.7,我正在使用pyinstaller。我的目标是输出一个exe文件,并让它运行我的其他类文件。我也使用https://code.google.com/p/dragonfly/作为语音识别的框架。我在蜻蜓 - > examples-> text.py下的示例方向中创建了另一个文件。如果我用我的IDE运行https://code.google.com/p/dragonfly/source/browse/trunk/dragonfly/examples/dragonfly-main.py?spec=svn79&r=79,我可以说出语音命令,它会理解我创建的以下文件以及蜻蜓示例中的其他示例文件。python pyinstaller在创建exe后加载文件
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"
我的主脚本dragonfly-main.py正在将目录中的每个示例文件作为模块加载。它可以在IDE中做到这一点,但是在使用pyinstaller时,无论出于何种原因,它都不会获得我的示例文件。蜻蜓主要不知道其他模块是什么。 – tiggles 2013-03-23 02:58:13
示例文件是示例文件而非模块。创建你分离的项目,将蜻蜓导入它。如果您需要示例文件中的代码 - 将其复制并过滤到您的项目中,您需要多少。 – 2013-03-23 09:57:04
你说得对,我试图做的一切倒退哈哈。我是python的新手。谢谢你的帮助。 – tiggles 2013-03-24 16:20:21