pyinstaller .exe无法正常启动

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

您好我正在学习python我的学习。现在我试图使用pyinstaller获取.exe文件,因为它更容易分享。

我的小程序使用tkinter,numpy和matplotlib,但是当我尝试启动它时,没有任何反应,它非常奇怪,因为我在编译过程中没有错误:

    pyinstaller main.spec
531 INFO: PyInstaller: 3.4.dev0+133d18156
531 INFO: Python: 3.6.2
531 INFO: Platform: Windows-10-10.0.15063-SP0
531 INFO: UPX is not available.
531 INFO: Extending PYTHONPATH with paths
['C:\\Users\\Charles\\eclipse-workspace\\algo2\\src',
 'C:\\Users\\Charles\\eclipse-workspace\\algo2\\src']
531 INFO: checking Analysis
531 INFO: Building Analysis because out00-Analysis.toc is non existent
531 INFO: Initializing module dependency graph...
546 INFO: Initializing module graph hooks...
578 INFO: Analyzing base_library.zip ...
4672 INFO: Analyzing hidden import 'os'
4719 INFO: Analyzing hidden import 'stat'
4719 INFO: Analyzing hidden import 'ntpath'
4781 INFO: Analyzing hidden import 'genericpath'
4797 INFO: running Analysis out00-Analysis.toc
4812 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\charles\anaconda3\python.exe
5906 INFO: Caching module hooks...
5922 INFO: Analyzing main.py
5937 INFO: Loading module hooks...
5937 INFO: Loading module hook "hook-encodings.py"...
6078 INFO: Looking for ctypes DLLs
6078 INFO: Analyzing run-time hooks ...
6078 INFO: Looking for dynamic libraries
6078 INFO: Looking for eggs
6078 INFO: Using Python library c:\users\charles\anaconda3\python36.dll
6078 INFO: Found binding redirects:
[]
6109 INFO: Graph cross-reference written to C:\Users\Charles\eclipse-workspace\algo2\src\build\main\xref-main.html
6141 INFO: checking PYZ
6141 INFO: Building PYZ because out00-PYZ.toc is non existent
6141 INFO: Building PYZ (ZlibArchive) C:\Users\Charles\eclipse-workspace\algo2\src\build\main\out00-PYZ.pyz
6344 INFO: Building PYZ (ZlibArchive) C:\Users\Charles\eclipse-workspace\algo2\src\build\main\out00-PYZ.pyz completed successfully.
6344 INFO: checking PKG
6344 INFO: Building PKG because out00-PKG.toc is non existent
6344 INFO: Building PKG (CArchive) out00-PKG.pkg
6406 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
6422 INFO: Bootloader c:\users\charles\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\run_d.exe
6422 INFO: checking EXE
6422 INFO: Building EXE because out00-EXE.toc is non existent
6422 INFO: Building EXE from out00-EXE.toc
6422 INFO: Appending archive to EXE C:\Users\Charles\eclipse-workspace\algo2\src\build\main\main.exe
6516 INFO: Building EXE from out00-EXE.toc completed successfully.
6531 INFO: checking COLLECT
6531 INFO: Building COLLECT because out00-COLLECT.toc is non existent
6547 INFO: Building COLLECT out00-COLLECT.toc
7359 INFO: Building COLLECT out00-COLLECT.toc completed successfully.

所以我试着用debug编译,我没有看到错误:

main.exe>log.txt
[3912] PyInstaller Bootloader 3.x
[3912] LOADER: executable is C:\Users\Charles\eclipse-workspace\algo2\src\dist\main\main.exe
[3912] LOADER: homepath is C:\Users\Charles\eclipse-workspace\algo2\src\dist\main
[3912] LOADER: _MEIPASS2 is NULL
[3912] LOADER: archivename is C:\Users\Charles\eclipse-workspace\algo2\src\dist\main\main.exe
[3912] LOADER: No need to extract files to run; setting extractionpath to homepath
[3912] LOADER: SetDllDirectory(C:\Users\Charles\eclipse-workspace\algo2\src\dist\main)
[3912] LOADER: Already in the child - running user's code.
[3912] LOADER: Python library: C:\Users\Charles\eclipse-workspace\algo2\src\dist\main\python36.dll
[3912] LOADER: Loaded functions from Python library.
[3912] LOADER: Manipulating environment (sys.path, sys.prefix)
[3912] LOADER: Pre-init sys.path is C:\Users\Charles\eclipse-workspace\algo2\src\dist\main\base_library.zip;C:\Users\Charles\eclipse-workspace\algo2\src\dist\main
[3912] LOADER: sys.prefix is C:\Users\Charles\eclipse-workspace\algo2\src\dist\main
[3912] LOADER: Setting runtime options
[3912] LOADER: Initializing python
[3912] LOADER: Overriding Python's sys.path
[3912] LOADER: Post-init sys.path is C:\Users\Charles\eclipse-workspace\algo2\src\dist\main\base_library.zip;C:\Users\Charles\eclipse-workspace\algo2\src\dist\main
[3912] LOADER: Setting sys.argv
[3912] LOADER: setting sys._MEIPASS
[3912] LOADER: importing modules from CArchive
[3912] LOADER: extracted struct
[3912] LOADER: callfunction returned...
[3912] LOADER: extracted pyimod01_os_path
[3912] LOADER: callfunction returned...
[3912] LOADER: extracted pyimod02_archive
[3912] LOADER: callfunction returned...
[3912] LOADER: extracted pyimod03_importers
[3912] LOADER: callfunction returned...
[3912] LOADER: Installing PYZ archive with Python modules.
[3912] LOADER: PYZ archive: out00-PYZ.pyz
[3912] LOADER: Running pyiboot01_bootstrap.py
[3912] LOADER: OK.
[3912] LOADER: Cleaning up Python interpreter.

这是我的.spec文件:

# -*- mode: python -*-
import sys

block_cipher = None


a = Analysis(['main.py'],
             pathex=['C:\\Users\\Charles\\eclipse-workspace\\algo2\\src'],
             binaries=[],
             datas=[],
             hiddenimports=['os', 'stat', 'ntpath', 'genericpath'],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher
             )
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher
             )
exe = EXE(pyz,
          a.binaries + [('msvcp100.dll', 'C:\\Windows\\System32\\msvcp100.dll', 'BINARY'),
                        ('msvcr100.dll', 'C:\\Windows\\System32\\msvcr100.dll', 'BINARY')]
          if sys.platform == 'win32' else a.binaries,
          exclude_binaries=True,
          name='main',
          debug=False,
          strip=False,
          upx=False,
          console=False )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=False,
               name='main')

如果我使用python解释器运行它,我的程序没有问题。尝试使用和不使用控制台启动.exe,没有任何反应。

任何的想法 ?

谢谢

谢谢

python pyinstaller
1个回答
0
投票

你是怎么告诉pyinstaller编译.py文件的?

如果您使用pip安装了pyinstaller,请尝试运行此命令提示符与文件位于同一目录中。

pyinstaller mypythonapp.py

.exe将在一个名为dist的新目录中。要将exe作为一个文件获取,请在编译时在命令提示符中使用--onefile参数。

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