1

私は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: []

そのため、サンプルが見つからないため、サンプルをロードしていません。exeを作成するときにサンプルファイルもロードするようにpyinstallerに指示するにはどうすればよいですか? そして、ファイルがロードされる場合、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"
4

1 に答える 1

0

はっきり分かれば。スクリプトと、スクリプトが機能していることを示すためにスクリプトを呼び出すいくつかのサンプル スクリプトがありますか?

あなたは要点を逃しています。あなたのスクリプトは最終製品であると想定しています。

機能をテストしたい場合は、開発版で行ってください。
exeファイルをテストしたい場合は、別の(分離された)テストスクリプトで実行してください。

その他:
スクリプトとモジュールはまったく別のものです。
スクリプトをモジュールとしてインポートし、サンプル スクリプトで使用しようとしています。

スクリプトへのメインエントリ ポイントを作成することをお勧めします (必要に応じてパラメーターを使用)。そして、スクリプトを実行する他のサンプル スクリプトを作成します。

または、モジュールを作成し、このモジュールを使用するスクリプトをビルドします。次に、このサンプル スクリプトをビルドして、そのモジュールを使用し、動作することを示す exe ファイルを作成します。

PyInstaller は一度に 1 つのスクリプトをコンパイルできます。異常なことを強制する必要はありません。

于 2013-03-22T23:28:00.123 に答える