程序打包
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[Python]]
&color(red){※This article is based on Python 3.7.3};
#contents
* 概要 [#dd2f32bb]
** 为什么要将 Python 程序打包为 exe 可执行文件 [#s65e8ed7]
众所周知,Python 程序的运行必须要有 Python 的环境,但是程...
** 为什么 Python 程序不能直接运行呢 [#i13850a7]
Python 是解释性语言,它与 C 或者 C++ 等编译型语言不同,C ...
* 安装 Pyinstaller [#zb12a9ac]
这个用 pip 模块直接下载就行,直接就下载在本次需要打包的 P...
pip install Pyinstaller
* 使用 [#h40033b0]
命令格式如下
Pyinstaller -option1 -option2 -... 要打包的文件
|参数选项|描述|h
|-F, -onefile|只生成一个单个文件(只有一个 exe 文件)|
|-D, -onedir|打包多个文件,在dist中生成很多依赖文件,适合...
|-K, –tk|在部署时包含 TCL/TK|
|-i -icon=<FILE.ICO>|将 file.ico 添加为可执行文件的资源(...
这里简单地举几个例子,让大家明白这个参数怎么写。
# 这一般是用来打包界面化的程序的,如用tkinter、Pyqt5等制...
# -w 的意思就是exe运行的时候不弹出那个命令行(黑窗口)
#codeprettify{{
Pyinstaller -F -w somefile.py# 这一般用来添加exe的图标
Pyinstaller -F -i someicon.ico somefile.py
}}
* Troubleshooting [#v0d64200]
** 打包后报错提示有些文件找不到 [#w315d3c3]
#codeprettify{{
Traceback (most recent call last):
File "fastwhisper3.py", line 25, in <module>
segments, info = model.transcribe(wavfile, beam_size=...
File "faster_whisper\transcribe.py", line 333, in trans...
File "faster_whisper\vad.py", line 74, in get_speech_ti...
File "faster_whisper\vad.py", line 229, in get_vad_model
File "faster_whisper\vad.py", line 246, in __init__
File "onnxruntime\capi\onnxruntime_inference_collection...
File "onnxruntime\capi\onnxruntime_inference_collection...
onnxruntime.capi.onnxruntime_pybind11_state.NoSuchFile: [...
[4424] Failed to execute script 'fastwhisper3' due to unh...
}}
使用 --hidden-import 参数也提示找不到
>pyinstaller --hidden-import WhisperModel fasterwhisper.py
# 找不到下面的
12304 ERROR: Hidden import 'WhisperModel' not found
这里的import不要使用代码中 import 后面的模块名,而是应该...
* 其他的打包工具 [#cbe59c2a]
** py2exe [#z7957e0a]
py2exe可以将Python代码打包成Windows可执行文件。
使用py2exe打包Python代码也很简单,只需要在命令行中输入以...
python setup.py py2exe
这将生成一个Windows可执行文件。
** py2app [#e7369322]
py2app可以将Python代码打包成MacOS可执行文件。
使用py2app打包Python代码也很简单,只需要在命令行中输入以...
python setup.py py2app
这将生成一个MacOS可执行文件。
** cx_Freeze [#s57f5ba2]
cx_Freeze可以将Python代码打包成独立的可执行文件。
使用cx_Freeze打包Python代码也很简单,只需要在命令行中输入...
cxfreeze xxx.py --target-dir distflord
这将生成一个可执行文件,可以在Windows、Linux和MacOS上运行。
#hr();
コメント:
#comment_kcaptcha
終了行:
[[Python]]
&color(red){※This article is based on Python 3.7.3};
#contents
* 概要 [#dd2f32bb]
** 为什么要将 Python 程序打包为 exe 可执行文件 [#s65e8ed7]
众所周知,Python 程序的运行必须要有 Python 的环境,但是程...
** 为什么 Python 程序不能直接运行呢 [#i13850a7]
Python 是解释性语言,它与 C 或者 C++ 等编译型语言不同,C ...
* 安装 Pyinstaller [#zb12a9ac]
这个用 pip 模块直接下载就行,直接就下载在本次需要打包的 P...
pip install Pyinstaller
* 使用 [#h40033b0]
命令格式如下
Pyinstaller -option1 -option2 -... 要打包的文件
|参数选项|描述|h
|-F, -onefile|只生成一个单个文件(只有一个 exe 文件)|
|-D, -onedir|打包多个文件,在dist中生成很多依赖文件,适合...
|-K, –tk|在部署时包含 TCL/TK|
|-i -icon=<FILE.ICO>|将 file.ico 添加为可执行文件的资源(...
这里简单地举几个例子,让大家明白这个参数怎么写。
# 这一般是用来打包界面化的程序的,如用tkinter、Pyqt5等制...
# -w 的意思就是exe运行的时候不弹出那个命令行(黑窗口)
#codeprettify{{
Pyinstaller -F -w somefile.py# 这一般用来添加exe的图标
Pyinstaller -F -i someicon.ico somefile.py
}}
* Troubleshooting [#v0d64200]
** 打包后报错提示有些文件找不到 [#w315d3c3]
#codeprettify{{
Traceback (most recent call last):
File "fastwhisper3.py", line 25, in <module>
segments, info = model.transcribe(wavfile, beam_size=...
File "faster_whisper\transcribe.py", line 333, in trans...
File "faster_whisper\vad.py", line 74, in get_speech_ti...
File "faster_whisper\vad.py", line 229, in get_vad_model
File "faster_whisper\vad.py", line 246, in __init__
File "onnxruntime\capi\onnxruntime_inference_collection...
File "onnxruntime\capi\onnxruntime_inference_collection...
onnxruntime.capi.onnxruntime_pybind11_state.NoSuchFile: [...
[4424] Failed to execute script 'fastwhisper3' due to unh...
}}
使用 --hidden-import 参数也提示找不到
>pyinstaller --hidden-import WhisperModel fasterwhisper.py
# 找不到下面的
12304 ERROR: Hidden import 'WhisperModel' not found
这里的import不要使用代码中 import 后面的模块名,而是应该...
* 其他的打包工具 [#cbe59c2a]
** py2exe [#z7957e0a]
py2exe可以将Python代码打包成Windows可执行文件。
使用py2exe打包Python代码也很简单,只需要在命令行中输入以...
python setup.py py2exe
这将生成一个Windows可执行文件。
** py2app [#e7369322]
py2app可以将Python代码打包成MacOS可执行文件。
使用py2app打包Python代码也很简单,只需要在命令行中输入以...
python setup.py py2app
这将生成一个MacOS可执行文件。
** cx_Freeze [#s57f5ba2]
cx_Freeze可以将Python代码打包成独立的可执行文件。
使用cx_Freeze打包Python代码也很简单,只需要在命令行中输入...
cxfreeze xxx.py --target-dir distflord
这将生成一个可执行文件,可以在Windows、Linux和MacOS上运行。
#hr();
コメント:
#comment_kcaptcha
ページ名: