[software development] deepin 23中使用pyinstaller打包遇到的dist文件夹内容为空
Tofloor
poster avatar
pho
deepin
2024-10-11 16:28
Author

各位站友,我在deepin23用pyinstaller打包,运行pyinstaler 后,dist文件夹为空,这个怎么解决?

运行代码经过如下:

pho@Light:~/Downloads$ pyinstaller eGFR.py
39 INFO: PyInstaller: 6.10.0, contrib hooks: 2024.8
39 INFO: Python: 3.12.4
40 INFO: Platform: Linux-6.6.47-amd64-desktop-hwe-x86_64-with-glibc2.38
40 INFO: Python environment: /home/pho/.local/pipx/venvs/pyinstaller
40 INFO: wrote /home/pho/Downloads/eGFR.spec
41 INFO: Module search paths (PYTHONPATH):
['/usr/lib/python312.zip',
 '/usr/lib/python3.12',
 '/usr/lib/python3.12/lib-dynload',
 '/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages',
 '/home/pho/.local/pipx/shared/lib/python3.12/site-packages',
 '/home/pho/.local/pipx/shared/lib/python3.12/site-packages/setuptools/_vendor',
 '/home/pho/Downloads']
98 INFO: checking Analysis
98 INFO: Building Analysis because Analysis-00.toc is non existent
98 INFO: Running Analysis Analysis-00.toc
98 INFO: Target bytecode optimization level: 0
98 INFO: Initializing module dependency graph...
98 INFO: Caching module graph hooks...
102 INFO: Analyzing base_library.zip ...
413 INFO: Processing standard module hook 'hook-heapq.py' from '/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/hooks'
653 INFO: Processing standard module hook 'hook-encodings.py' from '/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/hooks'
1453 INFO: Processing standard module hook 'hook-pickle.py' from '/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/hooks'
2277 INFO: Caching module dependency graph...
2321 INFO: Looking for Python shared library...
Traceback (most recent call last):
  File "/home/pho/.local/bin/pyinstaller", line 8, in 
    sys.exit(_console_script_run())
             ^^^^^^^^^^^^^^^^^^^^^
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/__main__.py", line 231, in _console_script_run
    run()
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/__main__.py", line 215, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/__main__.py", line 70, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1227, in main
    build(specfile, distpath, workpath, clean_build)
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 1167, in build
    exec(code, spec_namespace)
  File "/home/pho/Downloads/eGFR.spec", line 4, in 
    a = Analysis(
        ^^^^^^^^^
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 558, in __init__
    self.__postinit__()
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/building/datastruct.py", line 184, in __postinit__
    self.assemble()
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/building/build_main.py", line 668, in assemble
    python_lib = bindepend.get_python_library_path()
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/depend/bindepend.py", line 814, in get_python_library_path
    python_libname = findLibrary(name)
                     ^^^^^^^^^^^^^^^^^
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/depend/bindepend.py", line 587, in resolve_library_path
    fullpath = _resolve_library_path_unix(name)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/depend/bindepend.py", line 667, in _resolve_library_path_unix
    utils.load_ldconfig_cache()
  File "/home/pho/.local/pipx/venvs/pyinstaller/lib/python3.12/site-packages/PyInstaller/depend/utils.py", line 326, in load_ldconfig_cache
    from distutils.spawn import find_executable
ModuleNotFoundError: No module named 'distutils'
Reply Favorite View the author
All Replies
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-10-11 22:44
#1

我python的话常用的是nuitka打包的

你要先用pip在你的python环境安装nuitka

pip install nuitka

打包命令

nuitka  --show-progress --standalone --disable-console  --output-dir=out   --remove-output    --plugin-enable=pyqt5   --output-filename=xxxxxxxxxxxxxx  --follow-imports    --include-package-data=res main.py

--output-filename=你想生成的的程序名称

--follow-imports 这个意思是自动把需要用到的第三方库模块一起导进来

--plugin-enable=pyqt5 项目假如用到pyqt5就加这些参数进去

--include-package-data=res 程序需要用到的资源(图片音乐等)的文件夹‘’res‘’你自己根据你的文件夹名称修改这个

--output-dir=out就是到时候输出生成的程序所在的文件夹

Reply View the author
Oli
deepin
2024-10-12 04:28
#2

agree

Reply View the author
pho
deepin
2024-10-12 08:36
#3
把一切操作变成GUI

我python的话常用的是nuitka打包的

你要先用pip在你的python环境安装nuitka

pip install nuitka

打包命令

nuitka  --show-progress --standalone --disable-console  --output-dir=out   --remove-output    --plugin-enable=pyqt5   --output-filename=xxxxxxxxxxxxxx  --follow-imports    --include-package-data=res main.py

--output-filename=你想生成的的程序名称

--follow-imports 这个意思是自动把需要用到的第三方库模块一起导进来

--plugin-enable=pyqt5 项目假如用到pyqt5就加这些参数进去

--include-package-data=res 程序需要用到的资源(图片音乐等)的文件夹‘’res‘’你自己根据你的文件夹名称修改这个

--output-dir=out就是到时候输出生成的程序所在的文件夹

我没有用过这个,请教:

--output-filename=你想生成的的程序名称:这个名称要不要带后缀如deb,exe,比如main.deb或main.exe?

--follow-imports 这个意思是自动把需要用到的第三方库模块一起导进来

--plugin-enable=pyqt5 项目假如用到pyqt5就加这些参数进去:如果用的tk-inter,用不用--plugin-enable=tk-inter?

--include-package-data=res 程序需要用到的资源(图片音乐等)的文件夹‘’res‘’你自己根据你的文件夹名称修改这个:这个res里面软件图标这样的文件存在在此吗?

--output-dir=out就是到时候输出生成的程序所在的文件夹

Reply View the author
151******07
deepin
2024-10-12 09:09
#4
No module named 'distutils'
Reply View the author
兆兆嘟嘟嘟
deepin
2024-10-12 11:07
#5
把一切操作变成GUI

我python的话常用的是nuitka打包的

你要先用pip在你的python环境安装nuitka

pip install nuitka

打包命令

nuitka  --show-progress --standalone --disable-console  --output-dir=out   --remove-output    --plugin-enable=pyqt5   --output-filename=xxxxxxxxxxxxxx  --follow-imports    --include-package-data=res main.py

--output-filename=你想生成的的程序名称

--follow-imports 这个意思是自动把需要用到的第三方库模块一起导进来

--plugin-enable=pyqt5 项目假如用到pyqt5就加这些参数进去

--include-package-data=res 程序需要用到的资源(图片音乐等)的文件夹‘’res‘’你自己根据你的文件夹名称修改这个

--output-dir=out就是到时候输出生成的程序所在的文件夹

这个组件和pyinstaller相比如何?

Reply View the author
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-10-12 14:03
#6
兆兆嘟嘟嘟

这个组件和pyinstaller相比如何?

省事,方便

Reply View the author
把一切操作变成GUI
deepin
Backbone of ecological co-construction group
2024-10-12 14:10
#7
pho

我没有用过这个,请教:

--output-filename=你想生成的的程序名称:这个名称要不要带后缀如deb,exe,比如main.deb或main.exe?

--follow-imports 这个意思是自动把需要用到的第三方库模块一起导进来

--plugin-enable=pyqt5 项目假如用到pyqt5就加这些参数进去:如果用的tk-inter,用不用--plugin-enable=tk-inter?

--include-package-data=res 程序需要用到的资源(图片音乐等)的文件夹‘’res‘’你自己根据你的文件夹名称修改这个:这个res里面软件图标这样的文件存在在此吗?

--output-dir=out就是到时候输出生成的程序所在的文件夹

生成出来的是带相关库文件,还有软件启动的可执行程序,是没有后缀的,直接就一个main,双击执行。你到时候要再打包才会变成.deb,appimage,linyaps玲珑包,flatpak这些格式

是的,--plugin-enable=tk-inter

得看你的项目是调用的哪个文件夹的资源,你的文件夹叫tupin那就res改成tupian,是pic就改成pic

你可以尝试一下看看效果,反正又不影响你的源代码,你也可以搜索一下相关的资料,b站和官网都有

Reply View the author
187******09
deepin
2024-10-12 14:43
#8

最后不是报错没有 distutils 模块么

Reply View the author