afrcmg 2022-08-17 14:55 采纳率: 87.5%
浏览 844
已结题

Nuitka打包过程中遇到的问题

练习使用nuitka对python进行打包。
写了一个简单的main.py文件:

import json
import PySimpleGUI as sg

with open('./data/abc.json') as f:
    a = json.load(f)
print(a)
sg.popup('ok')

然后就对这个文件打包。但是一直都是失败

img


上面这个是经常用的命令,出现的结果,就是卡在这里不动了,好像昨天有一次我等了很久,出现了后续:
PS F:\小程序\demo> nuitka --standalone --nofollow-imports main.py
Nuitka-Options:INFO: Used command line options: --standalone --nofollow-imports main.py
Nuitka-Options:WARNING: Following no imports is unlikely to work for standalone mode and should not be specified.
Nuitka:INFO: Starting Python compilation with Nuitka '1.0.4' on Python '3.8' commercial grade 'not installed'.
Nuitka-Plugins:WARNING: Use '--enable-plugin=numpy' for: Numpy may miss DLLs otherwise.
Nuitka-Plugins:INFO: multiprocessing: Injecting pre-module load code for module 'multiprocessing':
Nuitka-Plugins:INFO: multiprocessing: Monkey patching "multiprocessing" load environment.
Nuitka-Plugins:INFO: multiprocessing: Injecting post-module load code for module 'multiprocessing':
Nuitka-Plugins:INFO: multiprocessing: Monkey patching "multiprocessing" for compiled methods.
Nuitka:INFO: Completed Python level compilation and optimization.
Nuitka:INFO: Generating source code for C backend compiler.
Nuitka:INFO: Running data composer tool for optimal constant value handling.
Nuitka:INFO: Running C compilation via Scons.
Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
Nuitka-Scons:INFO: Backend linking program with 200 files (no progress information available).
(在这里卡了1小时多)
Nuitka-Scons:INFO: Running 'D:\Program Files\Surpport_python\mingw64\bin\gcc.exe -o "F:\小程序\demo\MAIN~1.DIS\main.exe" -fuse-linker-plugin -flto=8 -fpartial-inlining -freorder-functions -Wl,--exclude-all-symbols -Wl,--out-implib,.\import.lib -municode -O3 -s -Wl,--enable-auto-import -Wl,--stack,9863168 -static-libgcc @".\@link_input.txt" -LC:\Users\JC\AppData\Local\Programs\Python\Python38\libs -lm -lpython38' took 3857.55 seconds
lto-wrapper.exe: warning: using serial compilation of 128 LTRANS jobs
lto-wrapper.exe: note: see the '-flto' option documentation for more information

Nuitka-Scons:INFO: Compiled 401 C files using ccache.
Nuitka-Scons:INFO: Cached C files (using ccache) with result 'cache hit': 201
Nuitka:INFO: Keeping build directory 'main.build'.
Nuitka:INFO: Successfully created 'main.dist\main.exe'.

但是它打包出来的似乎不能用.
但是不说能不能用,首先花那么久时间明显不正常。不知道有没有对此有研究的人来指点一下,该怎么处理。

对了,今天我换了个命令,结果是卡在这里:

img

  • 写回答

2条回答 默认 最新

  • afrcmg 2022-08-17 15:57
    关注

    等了很久终于等到结果了,就是第一张截图,卡在那里。之后的结果。

    Microsoft Windows [版本 10.0.19044.1889]
    (c) Microsoft Corporation。保留所有权利。
    
    F:\小程序\demo>nuitka --standalone --nofollow-imports main.py
    Nuitka-Options:INFO: Used command line options: --standalone --nofollow-imports main.py
    Nuitka-Options:WARNING: Following no imports is unlikely to work for standalone mode and should not be specified.
    Nuitka:INFO: Starting Python compilation with Nuitka '1.0.4' on Python '3.8' commercial grade 'not installed'.
    Nuitka-Plugins:WARNING: Use '--enable-plugin=numpy' for: Numpy may miss DLLs otherwise.
    Nuitka-Plugins:INFO: multiprocessing: Injecting pre-module load code for module 'multiprocessing':
    Nuitka-Plugins:INFO: multiprocessing:     Monkey patching "multiprocessing" load environment.
    Nuitka-Plugins:INFO: multiprocessing: Injecting post-module load code for module 'multiprocessing':
    Nuitka-Plugins:INFO: multiprocessing:     Monkey patching "multiprocessing" for compiled methods.
    Nuitka:INFO: Completed Python level compilation and optimization.
    Nuitka:INFO: Generating source code for C backend compiler.
    Nuitka:INFO: Running data composer tool for optimal constant value handling.
    Nuitka:INFO: Running C compilation via Scons.
    Nuitka-Scons:INFO: Backend C compiler: gcc (gcc).
    Nuitka-Scons:INFO: Backend linking program with 200 files (no progress information available).
    Nuitka-Scons:INFO: Running 'D:\\Program Files\\Surpport_python\\mingw64\\bin\\gcc.exe -o "F:\\小程序\\demo\\MAIN~1.DIS\\main.exe" -fuse-linker-plugin -flto=8 -fpartial-inlining -freorder-functions -Wl,--exclude-all-symbols -Wl,--out-implib,.\\import.lib -municode -O3 -s -Wl,--enable-auto-import -Wl,--stack,9863168 -static-libgcc @".\\@link_input.txt" -LC:\\Users\\JC\\AppData\\Local\\Programs\\Python\\Python38\\libs -lm -lpython38' took 3140.95 seconds
    lto-wrapper.exe: warning: using serial compilation of 128 LTRANS jobs
    lto-wrapper.exe: note: see the '-flto' option documentation for more information
    
    Traceback (most recent call last):
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\__main__.py", line 138, in <module>
        main()
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\__main__.py", line 124, in main
        MainControl.main()
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\MainControl.py", line 930, in main
        result, options = compileTree()
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\MainControl.py", line 845, in compileTree
        result, options = runSconsBackend(quiet=not Options.isShowScons())
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\MainControl.py", line 701, in runSconsBackend
        SconsInterface.runScons(
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\build\SconsInterface.py", line 286, in runScons
        checkCachingSuccess(source_dir or options["source_dir"])
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\build\SconsCaching.py", line 342, in checkCachingSuccess
        stats = _getCcacheStatistics(ccache_logfile)
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\build\SconsCaching.py", line 288, in _getCcacheStatistics
        for line in getFileContentByLine(ccache_logfile):
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\utils\FileOperations.py", line 562, in getFileContentByLine
        return getFileContents(filename, mode, encoding=encoding).splitlines()
      File "C:\Users\JC\AppData\Local\Programs\Python\Python38\lib\site-packages\nuitka\utils\FileOperations.py", line 580, in getFileContents
        return f.read()
    UnicodeDecodeError: 'gbk' codec can't decode byte 0xf2 in position 13743: illegal multibyte sequence
    
    
    
    
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 8月25日
  • 创建了问题 8月17日

悬赏问题

  • ¥15 编辑cmake lists 明明写了project项目名,但是还是报错怎么回事
  • ¥15 关于#计算机视觉#的问题:求一份高质量桥梁多病害数据集
  • ¥50 如何将脑的图像投影到颅骨上
  • ¥15 提问一个关于vscode相关的环境配置问题,就是输入中文但是显示不出来,代码在idea可以显示中文,但在vscode不行,不知道怎么配置环境
  • ¥15 netcore使用PuppeteerSharp截图
  • ¥20 这张图页头,页脚具体代码该怎么写?
  • ¥15 关于#sql#的问题,请各位专家解答!
  • ¥20 WPF MVVM模式 handycontrol 框架, hc:SearchBar 控件 Text="{Binding NavMenusKeyWords}" 绑定取不到值
  • ¥15 需要手写数字信号处理Dsp三个简单题 不用太复杂
  • ¥15 数字信号处理考试111