1

如果我使用pyinstaller我的 Python 脚本打包成一个.exe文件,当我运行该.exe文件时,它会抛出一个错误,如下所示:

  1. 将脚本打包成.exe文件,没有报错:

    (venv) E:\workspace\PycharmProjects\google-authenticator>pyinstaller -F --hidden-import=pyutil google-authenticator.py
    126 INFO: PyInstaller: 4.2
    126 INFO: Python: 3.8.6
    128 INFO: Platform: Windows-10-10.0.18362-SP0
    129 INFO: wrote E:\workspace\PycharmProjects\google-authenticator\google-authenticator.spec
    141 INFO: UPX is not available.
    142 INFO: Extending PYTHONPATH with paths
    ['E:\\workspace\\PycharmProjects\\google-authenticator',
     'E:\\workspace\\PycharmProjects\\google-authenticator']
    179 INFO: checking Analysis
    264 INFO: checking PYZ
    315 INFO: checking PKG
    330 INFO: Building because E:\workspace\PycharmProjects\google-authenticator\build\google-authenticator\google-authenticator.exe.manifest changed
    330 INFO: Building PKG (CArchive) PKG-00.pkg
    3027 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
    3031 INFO: Bootloader c:\python38\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run.exe
    3031 INFO: checking EXE
    3033 INFO: Rebuilding EXE-00.toc because google-authenticator.exe missing
    3033 INFO: Building EXE from EXE-00.toc
    3036 INFO: Copying icons from ['c:\\python38\\lib\\site-packages\\PyInstaller\\bootloader\\images\\icon-console.ico']
    3037 INFO: Writing RT_GROUP_ICON 0 resource with 104 bytes
    3038 INFO: Writing RT_ICON 1 resource with 3752 bytes
    3038 INFO: Writing RT_ICON 2 resource with 2216 bytes
    3038 INFO: Writing RT_ICON 3 resource with 1384 bytes
    3038 INFO: Writing RT_ICON 4 resource with 37019 bytes
    3039 INFO: Writing RT_ICON 5 resource with 9640 bytes
    3039 INFO: Writing RT_ICON 6 resource with 4264 bytes
    3039 INFO: Writing RT_ICON 7 resource with 1128 bytes
    3053 INFO: Updating manifest in E:\workspace\PycharmProjects\google-authenticator\build\google-authenticator\run.exe.ed6jwwbz
    3054 INFO: Updating resource type 24 name 1 language 0
    3058 INFO: Appending archive to EXE E:\workspace\PycharmProjects\google-authenticator\dist\google-authenticator.exe
    3070 INFO: Building EXE from EXE-00.toc completed successfully.
    
  2. 当我运行该.exe文件时,它遇到以下错误:

    E:\workspace\PycharmProjects\google-authenticator\dist>google-authenticator.exe
    Traceback (most recent call last):
      File "google-authenticator.py", line 6, in <module>
    ModuleNotFoundError: No module named 'pyutil'
    [37916] Failed to execute script google-authenticator
    
4

0 回答 0