如果没有控制台,则无法使用 pyinstaller 制作可执行文件

问题描述 投票:0回答:1

我正在尝试使用 pyinstaller 将我的脚本转换为可执行文件;但是,无论我尝试多少次,我都无法使其在不显示控制台窗口的情况下工作。

我录了:

pyinstaller --windowed --onefile --add-data:"dme.ui;." dme.py

这就是结果:

209 INFO: PyInstaller: 6.3.0
209 INFO: Python: 3.12.0
229 INFO: Platform: Windows-10-10.0.19045-SP0
229 INFO: wrote C:\Users\PC\Downloads\dme\dme.spec
234 INFO: Extending PYTHONPATH with paths
['C:\\Users\\PC\\Downloads\\dme']
475 INFO: Appending 'datas' from .spec
475 INFO: checking Analysis
475 INFO: Building Analysis because Analysis-00.toc is non existent
475 INFO: Initializing module dependency graph...
475 INFO: Caching module graph hooks...
485 INFO: Analyzing base_library.zip ...
1225 INFO: Loading module hook 'hook-encodings.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
2726 INFO: Loading module hook 'hook-pickle.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
3420 INFO: Loading module hook 'hook-heapq.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
3720 INFO: Caching module dependency graph...
3816 INFO: Running Analysis Analysis-00.toc
3816 INFO: Looking for Python shared library...
3822 INFO: Using Python shared library: C:\Users\PC\AppData\Local\Programs\Python\Python312\python312.dll
3822 INFO: Analyzing C:\Users\PC\Downloads\dme\dme.py
3830 INFO: Loading module hook 'hook-openpyxl.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\_pyinstaller_hooks_contrib\\hooks\\stdhooks'...
3941 INFO: Loading module hook 'hook-numpy.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\numpy\\_pyinstaller'...
4386 INFO: Loading module hook 'hook-difflib.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
4540 INFO: Loading module hook 'hook-multiprocessing.util.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
4661 INFO: Loading module hook 'hook-xml.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
5175 INFO: Loading module hook 'hook-platform.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
5200 INFO: Loading module hook 'hook-sysconfig.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
6535 INFO: Loading module hook 'hook-xml.etree.cElementTree.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
6791 INFO: Loading module hook 'hook-PIL.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
6862 INFO: Loading module hook 'hook-PIL.Image.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
7355 INFO: Loading module hook 'hook-packaging.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
7390 INFO: Loading module hook 'hook-PIL.ImageFilter.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
7732 INFO: Loading module hook 'hook-PyQt5.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
7805 INFO: Loading module hook 'hook-PyQt5.uic.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
7920 INFO: Processing pre-find module path hook PyQt5.uic.port_v2 from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-PyQt5.uic.port_v2.py'.
7975 INFO: Processing module hooks...
8040 INFO: Loading module hook 'hook-pkg_resources.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
8921 INFO: Loading module hook 'hook-PIL.SpiderImagePlugin.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
9306 WARNING: Hidden import "sip" not found!
9306 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
9407 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
9518 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
9630 INFO: Performing binary vs. data reclassification (106 entries)
9660 INFO: Looking for ctypes DLLs
9680 INFO: Analyzing run-time hooks ...
9680 INFO: Including run-time hook 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_inspect.py'
9685 INFO: Including run-time hook 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pyqt5.py'
9685 INFO: Processing pre-find module path hook _pyi_rth_utils from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\pre_find_module_path\\hook-_pyi_rth_utils.py'.
9688 INFO: Loading module hook 'hook-_pyi_rth_utils.py' from 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks'...
9688 INFO: Including run-time hook 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgutil.py'
9688 INFO: Including run-time hook 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_multiprocessing.py'
9693 INFO: Including run-time hook 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyInstaller\\hooks\\rthooks\\pyi_rth_pkgres.py'
9703 INFO: Looking for dynamic libraries
C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\build_main.py:194: UserWarning: The numpy.array_api submodule is still experimental. See NEP 47.
  __import__(package)
10217 INFO: Extra DLL search directories (AddDllDirectory): ['C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyQt5\\Qt5\\bin', 'C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\numpy.libs']
10217 INFO: Extra DLL search directories (PATH): ['C:\\Users\\PC\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\PyQt5\\Qt5\\bin']
10944 INFO: Warnings written to C:\Users\PC\Downloads\dme\build\dme\warn-dme.txt
11001 INFO: Graph cross-reference written to C:\Users\PC\Downloads\dme\build\dme\xref-dme.html
11029 INFO: checking PYZ
11034 INFO: Building PYZ because PYZ-00.toc is non existent
11034 INFO: Building PYZ (ZlibArchive) C:\Users\PC\Downloads\dme\build\dme\PYZ-00.pyz
11846 INFO: Building PYZ (ZlibArchive) C:\Users\PC\Downloads\dme\build\dme\PYZ-00.pyz completed successfully.
11866 INFO: checking PKG
11866 INFO: Building PKG because PKG-00.toc is non existent
11866 INFO: Building PKG (CArchive) dme.pkg
24755 INFO: Building PKG (CArchive) dme.pkg completed successfully.
24760 INFO: Bootloader C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\bootloader\Windows-64bit-intel\runw.exe
24760 INFO: checking EXE
24760 INFO: Building EXE because EXE-00.toc is non existent
24760 INFO: Building EXE from EXE-00.toc
24765 INFO: Copying bootloader EXE to C:\Users\PC\Downloads\dme\dist\dme.exe
24770 INFO: Copying icon to EXE
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 33, in pywin32error
    yield
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 209, in BeginUpdateResource
    return _resource._BeginUpdateResource(filename, delete)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32ctypes\core\ctypes\_util.py", line 39, in check_null
    raise make_error(function, function_name)
OSError: [WinError 225] Impossibile completare l'operazione. Il file contiene un virus o software potenzialmente indesiderato.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 214, in _console_script_run
    run()
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 198, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\__main__.py", line 69, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\build_main.py", line 1071, in main
    build(specfile, distpath, workpath, clean_build)
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\build_main.py", line 1011, in build
    exec(code, spec_namespace)
  File "C:\Users\PC\Downloads\dme\dme.spec", line 18, in <module>
    exe = EXE(
          ^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\api.py", line 628, in __init__
    self.__postinit__()
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__
    self.assemble()
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\api.py", line 741, in assemble
    self._retry_operation(icon.CopyIcons, build_name, self.icon)
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\building\api.py", line 1003, in _retry_operation
    return func(*args)
           ^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\utils\win32\icon.py", line 209, in CopyIcons
    return CopyIcons_FromIco(dstpath, [srcpath])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\PyInstaller\utils\win32\icon.py", line 143, in CopyIcons_FromIco
    hdst = win32api.BeginUpdateResource(dstpath, 0)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 208, in BeginUpdateResource
    with _pywin32error():
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\contextlib.py", line 155, in __exit__
    self.gen.throw(value)
  File "C:\Users\PC\AppData\Local\Programs\Python\Python312\Lib\site-packages\win32ctypes\pywin32\pywintypes.py", line 37, in pywin32error
    raise error(exception.winerror, exception.function, exception.strerror)
win32ctypes.pywin32.pywintypes.error: (225, 'BeginUpdateResourceW', "Impossibile completare l'operazione. Il file contiene un virus o software potenzialmente indesiderato.")

事实是,如果我尝试在没有 --windowed 选项的情况下编译 exe,它工作得很好。我做错了什么?

python pyinstaller
1个回答
0
投票

OSError:[WinError 225] 无法完成操作。 Il 文件包含病毒或软件潜力。

您的防病毒软件正在阻止该进程。如果您信任您的源代码和 pyinstaller 安装,并认为这是误报,请暂时禁用防病毒软件。

这样做需要您自担风险。

© www.soinside.com 2019 - 2024. All rights reserved.