Python打包
目录
前言
-
运行环境:Win10、Anaconda3。
-
下载所有示例代码。
Nuitka
安装
|
|
1 2 3 4 5Nuitka:INFO: Running C compilation via Scons. Traceback (most recent call last): File "C:\PROGRA~3\ANACON~1\lib\SITE-P~1\nuitka\build\INLINE~1\bin\scons.py", line 40, in <module> import SCons.Script # pylint: disable=import-error ModuleNotFoundError: No module named 'SCons'
1conda install -c conda-forge scons
1 2 3 4 5Is it OK to download and put it in 'C:\Users\m\AppData\Local\Nuitka\Nuitka\gcc\x86_64\11.2.0-12.0.1-9.0.0-r1'. No installer needed, cached, one time question. Proceed and download? [Yes]/No
Enter即可。
运行
|
|
--onefile:生成单文件。
--remove-output: 移除编译输出的中间文件。
--windows-icon-from-ico:exe图标。
1Nuitka-Onefile:WARNING: Onefile mode cannot compress without 'zstandard' module installed.
1conda install -c conda-forge zstandard
Pyinstaller
安装
|
|
运行
|
|
Embeddable
安装
下载Python 3.8.10 Windows embeddable package (64-bit)。
Note that Python 3.9 cannot be used on Windows 7 or earlier.
运行
新建.bat文件,
|
|
也可以不用
bat脚本,直接将.py文件拖拽到python.exe图标上。
Embeddable-Lite
只保留python-3.8.10-embed-amd64文件夹内的python.exe、python38.dll和python38.zip。
Embeddable-Plus
在Embeddable版本基础上增加Numpy、Matplotlib。
- 修改
python38._pth,将
|
|
改为,
|
|
- 下载get-pip.py,放置于
./python-3.8.10-embed-amd64内,拖拽到python.exe图标上。
1WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1131)'))': /simple/pip/
close proxy
在
./python-3.8.10-embed-amd64内新建pip.ini,
1 2[global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
- 在
./python-3.8.10-embed-amd64内打开cmd,
1python.exe get-pip.py
1 2 3python.exe -m pip install numpy python.exe -m pip install matplotlib python.exe -m pip install wxpython