python - 来自 pyinstaller 的 python 可执行文件的问题

标签 python compiler-errors exe pyinstaller

我使用 pyinstaller 创建了一个 exe(我使用的是 python 3.7.6 和 pyinstaller 3.6)

pyinstaller --onefile --icon=icon.ico my_script.py

(即使 pyinstaller --onedir --icon=icon.ico my_script.py 问题也是一样的)

该 exe 构建良好,但我在此过程中遇到多个错误:
25484 INFO: Excluding import 'PyQt5'
25486 INFO:   Removing import of PyQt5 from module PIL.ImageQt
25487 INFO: Import to be excluded not found: 'FixTk'
25488 INFO: Excluding import 'tkinter'
25490 INFO:   Removing import of tkinter from module PIL.ImageTk
25491 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
25496 INFO: Excluding import 'tkinter'
25498 INFO: Import to be excluded not found: 'FixTk'
25499 INFO: Loading module hook "hook-pkg_resources.py"...
26227 INFO: Processing pre-safe import module hook   win32com
26524 INFO: Excluding import '__main__'
26525 INFO:   Removing import of __main__ from module pkg_resources

尽管存在这些错误,但 exe 在某些计算机上可以正常工作,而在某些计算机上则不能。它不起作用的地方我在启动时收到此错误:
Traceback (most recent call last):
  File "my_script.py", line 39, in <module>
  File "c:\users\valerio\appdata\local\programs\python\python37-32\lib\site-pack
ages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
  File "site-packages\cv2\__init__.py", line 3, in <module>
ImportError: DLL load failed: The specified module could not be found.
[2800] Failed to execute script my_script

所以我的问题是:
  • 为什么我会收到内置错误?
  • 为什么在某些计算机上工作正常而有些则不行?第二个问题真的让我抓狂..

  • 谢谢你

    最佳答案

    我找到了我的问题的答案。我把它写在这里以防有人需要。
    问题出在 Windows Server 2008 和 2012 上。他们缺少一个名为“桌面体验”的模块。

    一旦安装它(例如使用 this 指南),错误就会消失。

    另一个类似的discussion

    关于python - 来自 pyinstaller 的 python 可执行文件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60903252/

    相关文章:

    python - 如何在 Python 上生成 DOT 语言输出

    c++ - 在 C++ 代码部分,可能会写入两个字节

    c# - 错误 "A template containing a class feature must end with a class feature"

    在 python 3.5 上执行的 Python 脚本

    python - 在 android 中编写 python(或任何其他 SL4A)

    Python:找不到 '__main__' 模块

    python - argparse 的默认参数

    java - Jar 存在于本地 Maven 存储库中,但仍然编译错误,错误为 "Package does not exist"

    c - c语言.exe文件命令的使用

    windows - 双模式可执行吗?