![](/img/trans.png)
[英]Error loading python37 dll on Windows 7 after Pyinstaller created exe
[英]Python pyinstaller loading files after exe creation
我正在運行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"
如果我明白了。 您有自己的腳本以及一些示例腳本,這些腳本調用您的腳本以表明其正常工作?
您錯過了重點。 您的腳本應該是最終產品。
如果要測試功能,請在開發版本中進行。
如果您要測試exe文件,請使用另一個(單獨的)測試腳本進行測試。
另一件事:
腳本和模塊是完全不同的東西。
您正在嘗試將腳本導入為模塊,並在示例腳本中使用它。
我建議您按需構建腳本的主要入口點 (如果需要,可以使用參數)。 並制作其他示例腳本來運行您的腳本。
或制作一個模塊並使用該模塊構建腳本。 然后將該示例腳本構建為使用該模塊的exe文件,並顯示其工作原理
PyInstaller可以一次編譯一個腳本。 不需要強迫它執行不尋常的事情。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.