老师 问一个pyinstaller打包问题。为啥本地运行没问题,打包成功了却运行不了。源代码
import speech_recognition as sr
infile='demo.wav'
r=sr.Recognizer()
with sr.AudioFile(infile) as f:
b=r.record(f)
with open('demo1.txt','a',encoding='utf-8') as g:
g.write(r.recognize_sphinx(b,language='zh-CN'))
错误提示:
删除dist及build文件夹,修改spec文件:
运行pyinstaller try.spec报错没有变化
将用到的模块路径加入环境变量,打包时指定模块路径,pyinstaller try.py -F -p E:\anaconda\Lib\site-packages没有效果,报错内容一模一样。
使用pyinstaller try.py -F –-hidden-import pocketsphinx打包没有效果,报错内容一样。
显式的导入缺失的包,报错少一项,但仍报缺失sphinxbase._ad_win32
import speech_recognition as sr, PocketSphinx, sphinxbase._ad_win32
infile='demo.wav'
r=sr.Recognizer()
with sr.AudioFile(infile) as f:
b=r.record(f)
with open('demo1.txt','a',encoding='utf-8') as g:
g.write(r.recognize_sphinx(b,language='zh-CN'))