无法运行pyins创建的exe文件

2024-10-01 00:21:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Pycharm编写.py源代码,当我在Pycharm中使用“Run”时,它工作得很好。 在我写完源代码之后,我想使用Pyinstaller将代码打包到可执行文件中,打包过程正常,并创建了.exe文件。 但是当我双击可执行文件时,没有任何反应。不知道怎么了,请帮帮我。Pyinstaller在txt文件中创建了一个警告报告,但我不认为这是主要原因,我还是把它附在了底部。在

    (venv) D:\Dropbox\Project\Pycharm Projects\biaobai>pyinstaller -F -w -i aixin.ico main.py
1405 INFO: PyInstaller: 3.3.1
1411 INFO: Python: 3.7.0
1413 INFO: Platform: Windows-10-10.0.17134-SP0
1418 INFO: wrote D:\Dropbox\Project\Pycharm Projects\biaobai\main.spec
1431 INFO: UPX is not available.
1448 INFO: Extending PYTHONPATH with paths
['D:\\Dropbox\\Project\\Pycharm Projects\\biaobai',
 'D:\\Dropbox\\Project\\Pycharm Projects\\biaobai']
1449 INFO: checking Analysis
1449 INFO: Building Analysis because out00-Analysis.toc is non existent
1450 INFO: Initializing module dependency graph...
1455 INFO: Initializing module graph hooks...
1458 INFO: Analyzing base_library.zip ...
6290 INFO: running Analysis out00-Analysis.toc
6321 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by D:\Dropbox\Project\Pycharm Projects\biaobai\venv\Scripts\python.exe
8194 INFO: Caching module hooks...
8206 INFO: Analyzing D:\Dropbox\Project\Pycharm Projects\biaobai\main.py
9513 INFO: Loading module hooks...
9513 INFO: Loading module hook "hook-encodings.py"...
9628 INFO: Loading module hook "hook-PIL.Image.py"...
10335 INFO: Processing pre-find module path hook   distutils
10591 INFO: Loading module hook "hook-PIL.py"...
10607 INFO: Excluding import 'PySide'
10609 INFO:   Removing import of PySide from module PIL.ImageQt
10611 INFO: Import to be excluded not found: 'FixTk'
10612 INFO: Excluding import 'tkinter'
10614 INFO:   Removing import of tkinter from module PIL.ImageTk
10615 INFO: Excluding import 'PyQt4'
10618 INFO:   Removing import of PyQt4 from module PIL.ImageQt
10619 INFO: Excluding import 'PyQt5'
10620 INFO:   Removing import of PyQt5 from module PIL.ImageQt
10621 INFO: Loading module hook "hook-PIL.SpiderImagePlugin.py"...
10651 INFO: Import to be excluded not found: 'FixTk'
10651 INFO: Excluding import 'tkinter'
10652 INFO: Loading module hook "hook-pydoc.py"...
10657 INFO: Loading module hook "hook-xml.py"...
11028 INFO: Loading module hook "hook-_tkinter.py"...
11438 INFO: checking Tree
11438 INFO: Building Tree because out00-Tree.toc is non existent
11439 INFO: Building Tree out00-Tree.toc
11549 INFO: checking Tree
11550 INFO: Building Tree because out01-Tree.toc is non existent
11550 INFO: Building Tree out01-Tree.toc
11566 INFO: Loading module hook "hook-distutils.py"...
11609 INFO: Looking for ctypes DLLs
11609 INFO: Analyzing run-time hooks ...
11613 INFO: Including run-time hook 'pyi_rth__tkinter.py'
11624 INFO: Looking for dynamic libraries
13929 INFO: Looking for eggs
13929 INFO: Using Python library D:\Dropbox\Project\Pycharm Projects\biaobai\venv\Scripts\python37.dll
13930 INFO: Found binding redirects:
[]
13934 INFO: Warnings written to D:\Dropbox\Project\Pycharm Projects\biaobai\build\main\warnmain.txt
14026 INFO: Graph cross-reference written to D:\Dropbox\Project\Pycharm Projects\biaobai\build\main\xref-main.html
14105 INFO: checking PYZ
14105 INFO: Building PYZ because out00-PYZ.toc is non existent
14105 INFO: Building PYZ (ZlibArchive) D:\Dropbox\Project\Pycharm Projects\biaobai\build\main\out00-PYZ.pyz
15080 INFO: Building PYZ (ZlibArchive) D:\Dropbox\Project\Pycharm Projects\biaobai\build\main\out00-PYZ.pyz completed successfully.
15095 INFO: checking PKG
15095 INFO: Building PKG because out00-PKG.toc is non existent
15096 INFO: Building PKG (CArchive) out00-PKG.pkg
18477 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
18528 INFO: Bootloader D:\Dropbox\Project\Pycharm Projects\biaobai\venv\lib\site-packages\PyInstaller\bootloader\Windows-32bit\runw.exe
18529 INFO: checking EXE
18529 INFO: Building EXE because out00-EXE.toc is non existent
18530 INFO: Building EXE from out00-EXE.toc
18555 INFO: SRCPATH [('aixin.ico', None)]
18555 INFO: Updating icons from ['aixin.ico'] to C:\Users\ADMINI~1\AppData\Local\Temp\tmp14uu9lyu
18556 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes
18556 INFO: Writing RT_ICON 1 resource with 28840 bytes
18566 INFO: appending archive to EXE D:\Dropbox\Project\Pycharm Projects\biaobai\dist\main.exe
18591 INFO: Building EXE from out00-EXE.toc completed successfully.

在沃恩曼.txt公司名称:

^{pr2}$

Tags: pyinfoprojecttreemainhookpycharmdropbox
2条回答

我试图用“pyinstaller-F”打包可执行文件主.py而不是使用pyinstaller-F-w主.py". 这使我能够通过CMD运行窗口应用程序,然后出现以下错误:

Fatal Python error: Py_Initialize: Unable to get the locale encoding

zipimport.ZipImportError: can't find module 'encodings' Current

thread 0x00003d20 (most recent call first):

通过搜索上面的错误消息,我想我得到了答案:[zipimport.ZipImportError: can't find module 'encodings' 结论应该是:pyinstaller3.3.1不支持python3.7。在

刚才,我试着把Python版本从3.7改为3.6.3,打包很好,最后,我可以正常运行.exe文件了。在

所发生的是,Pyinstaller无法找到脚本中使用的某些模块的路径。要解决这个问题,最简单的方法就是扩展路径。您可以在pycharm终端中运行它,将这些路径添加到specs文件中。或者可以编辑specs文件本身。在

pyi-makespec  paths=/path/to/thisdir \
              paths=/path/to/otherdir myscript.py

包括脚本可能正在搜索的所有其他位置进口。这些路径将添加到搜索路径在分析过程中。在

如果这对您无效,请尝试隐藏导入,扩展包路径并添加运行时钩子,如here所示。在

相关问题 更多 >