本文最后更新于 2025年1月24日。
国内pip源安装库
nuitka screenshot_250102.py --onefile --standalone
pip install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install openpyxl -i https://pypi.tuna.tsinghua.edu.cn/simple
首次使用nuitka打包
nuitka screenshot_250102.py --onefile --standalone
包含tkinter
nuitka screenshot_gui_250108.py --onefile --standalone --enable-plugin=tk-inter
耗时比较久但很成功
(env_autoscreen) PS E:\mydoc\sync_pc_home_work\pyfile\screenshot> nuitka screenshot_250102.py --onefile --standalone
Nuitka-Options: Used command line options: screenshot_250102.py --onefile --standalone
Nuitka: Starting Python compilation with Nuitka '2.5.9' on Python '3.13' commercial grade 'not installed'.
Nuitka-Plugins:anti-bloat: Not including 'socket' automatically in order to avoid bloat, but this may cause: can break calls of
Nuitka-Plugins:anti-bloat: 'email.utils.make_msgid()'.
Nuitka-Plugins:anti-bloat: Not including 'PIL.ImageQt' automatically in order to avoid bloat, but this may cause: PIL will not be
Nuitka-Plugins:anti-bloat: able to create Qt image objects.
Nuitka: Completed Python level compilation and optimization.
Nuitka: Generating source code for C backend compiler.
Nuitka: Running data composer tool for optimal constant value handling.
Nuitka: Running C compilation via Scons.
Nuitka-Scons: Backend C compiler: cl (cl 14.3).
Nuitka-Scons: Backend linking program with 259 files (no progress information available for this stage).
Nuitka-Scons: Compiled 259 C files using clcache with 0 cache hits and 259 cache misses.
Nuitka-Postprocessing: Creating single file from dist folder, this may take a while.
Nuitka-Onefile: Running bootstrap binary compilation via Scons.
Nuitka-Scons: Onefile C compiler: cl (cl 14.3).
Nuitka-Scons: Onefile linking program with 1 files (no progress information available for this stage).
Nuitka-Scons: Compiled 1 C files using clcache with 0 cache hits and 1 cache misses.
Nuitka-Onefile: Using compression for onefile payload.
Nuitka-Onefile: Onefile payload compression ratio (29.05%) size 39868922 to 11583352.
Nuitka-Onefile: Keeping onefile build directory 'screenshot_250102.onefile-build'.
Nuitka: Keeping dist folder 'screenshot_250102.dist' for inspection, no need to use it.
Nuitka: Keeping build directory 'screenshot_250102.build'.
Nuitka: Successfully created 'screenshot_250102.exe'.
更新nuitka
(env_autoscreen) PS C:\WINDOWS\system32>
>> pip install --upgrade nuitka -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Requirement already satisfied: nuitka in c:\programdata\anaconda3\envs\env_autoscreen\lib\site-packages (0.6.16)
Collecting nuitka
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0e/4f/7fbc65f7eafac14e426e24318ae49755bf5af8cc8da5784083da9959f03f/Nuitka-2.5.9.tar.gz (3.8 MB)
---------------------------------------- 3.8/3.8 MB 59.4 MB/s eta 0:00:00
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting ordered-set>=4.1.0 (from nuitka)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/33/55/af02708f230eb77084a299d7b08175cff006dea4f2721074b92cdb0296c0/ordered_set-4.1.0-py3-none-any.whl (7.6 kB)
Collecting zstandard>=0.15 (from nuitka)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a2/bf/c6aaba098e2d04781e8f4f7c0ba3c7aa73d00e4c436bcc0cf059a66691d1/zstandard-0.23.0-cp313-cp313-win_amd64.whl (495 kB)
Building wheels for collected packages: nuitka
Building wheel for nuitka (pyproject.toml) ... done
Created wheel for nuitka: filename=Nuitka-2.5.9-cp313-cp313-win_amd64.whl size=3479957 sha256=ce99d76210ec5f2137b3074f8c5be391d109612d0df08e2e09e39d1243b70360
Stored in directory: c:\users\weiyo\appdata\local\pip\cache\wheels\7e\fe\96\88bc95abef4bce0ce9646bfbc3c1f0b4f6f48aef7d5cf27737
Successfully built nuitka
Installing collected packages: zstandard, ordered-set, nuitka
Attempting uninstall: nuitka
Found existing installation: Nuitka 0.6.16
Uninstalling Nuitka-0.6.16:
Successfully uninstalled Nuitka-0.6.16
Successfully installed nuitka-2.5.9 ordered-set-4.1.0 zstandard-0.23.0