Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/336.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
执行使用Pyinstaller构建的Python应用程序会给出;无法执行脚本main";_Python_Python 3.x_Tkinter_Pyinstaller - Fatal编程技术网

执行使用Pyinstaller构建的Python应用程序会给出;无法执行脚本main";

执行使用Pyinstaller构建的Python应用程序会给出;无法执行脚本main";,python,python-3.x,tkinter,pyinstaller,Python,Python 3.x,Tkinter,Pyinstaller,我有一个python程序,它对GUI使用tkinter。我的python项目是一个PyCharm项目。它被组织为Project\main.pyProject\my\u class.pyProject\images\favicon.icoProject\common\util\util1.pyProject\venv在终端内部,我移动到C:\…\Desktop\Project文件夹中如果有人想知道终端的输出是什么,请运行pyinstaller--windowedmain.py 62 INFO: P

我有一个python程序,它对GUI使用
tkinter
。我的python项目是一个PyCharm项目。它被组织为

Project\main.py

Project\my\u class.py

Project\images\favicon.ico

Project\common\util\util1.py
Project\venv

在终端内部,我移动到
C:\…\Desktop\Project
文件夹中如果有人想知道终端的输出是什么,请运行
pyinstaller--windowedmain.py

62 INFO: PyInstaller: 3.5
62 INFO: Python: 3.7.5
62 INFO: Platform: Windows-10-10.0.17763-SP0
62 INFO: wrote C:\Users\User\Desktop\Project\main.spec
62 INFO: UPX is not available.
62 INFO: Extending PYTHONPATH with paths
['C:\\Users\\User\\Desktop\\Project',
 'C:\\Users\\User\\Desktop\\Project']
62 INFO: checking Analysis
78 INFO: Building Analysis because Analysis-00.toc is non existent
78 INFO: Initializing module dependency graph...
78 INFO: Initializing module graph hooks...
78 INFO: Analyzing base_library.zip ...
2124 INFO: running Analysis Analysis-00.toc
2124 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\user\appdata\local\programs\python\python37\python.exe
3900 INFO: Caching module hooks...
3900 INFO: Analyzing C:\Users\User\Desktop\Project\main.py
4306 INFO: Processing pre-find module path hook   distutils
5040 INFO: Processing pre-find module path hook   site
5040 INFO: site: retargeting to fake-dir 'c:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site-packages\\PyInstaller\\fake-modules'
5925 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
7668 INFO: Loading module hooks...
7668 INFO: Loading module hook "hook-distutils.py"...
7671 INFO: Loading module hook "hook-encodings.py"...
7743 INFO: Loading module hook "hook-lib2to3.py"...
7747 INFO: Loading module hook "hook-numpy.core.py"...
7845 INFO: Loading module hook "hook-numpy.py"...
7846 INFO: Loading module hook "hook-pkg_resources.py"...
8092 INFO: Processing pre-safe import module hook   win32com
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
8150 INFO: Processing pre-safe import module hook   win32com
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
8327 INFO: Loading module hook "hook-pydoc.py"...
8328 INFO: Loading module hook "hook-setuptools.py"...
8742 INFO: Loading module hook "hook-sysconfig.py"...
8742 INFO: Loading module hook "hook-xml.dom.domreg.py"...
8742 INFO: Loading module hook "hook-xml.py"...
8742 INFO: Loading module hook "hook-_tkinter.py"...
9133 INFO: checking Tree
9133 INFO: Building Tree because Tree-00.toc is non existent
9148 INFO: Building Tree Tree-00.toc
9211 INFO: checking Tree
9211 INFO: Building Tree because Tree-01.toc is non existent
9211 INFO: Building Tree Tree-01.toc
9258 INFO: Looking for ctypes DLLs
9273 INFO: Analyzing run-time hooks ...
9273 INFO: Including run-time hook 'pyi_rth_pkgres.py'
9289 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
9289 INFO: Including run-time hook 'pyi_rth__tkinter.py'
9289 INFO: Looking for dynamic libraries
18180 INFO: Looking for eggs
18180 INFO: Using Python library c:\users\user\appdata\local\programs\python\python37\python37.dll
18180 INFO: Found binding redirects:
[]
18180 INFO: Warnings written to C:\Users\User\Desktop\Project\build\main\warn-main.txt
18445 INFO: Graph cross-reference written to C:\Users\User\Desktop\Project\build\main\xref-main.html
18492 INFO: checking PYZ
18492 INFO: Building PYZ because PYZ-00.toc is non existent
18492 INFO: Building PYZ (ZlibArchive) C:\Users\User\Desktop\Project\build\main\PYZ-00.pyz
19259 INFO: Building PYZ (ZlibArchive) C:\Users\User\Desktop\Project\build\main\PYZ-00.pyz completed successfully.
19274 INFO: checking PKG
19274 INFO: Building PKG because PKG-00.toc is non existent
19274 INFO: Building PKG (CArchive) PKG-00.pkg
19290 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
19290 INFO: Bootloader c:\users\user\appdata\local\programs\python\python37\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe
19290 INFO: checking EXE
19290 INFO: Building EXE because EXE-00.toc is non existent
19290 INFO: Building EXE from EXE-00.toc
19290 INFO: Appending archive to EXE C:\Users\User\Desktop\Project\build\main\main.exe
19306 INFO: Building EXE from EXE-00.toc completed successfully.
19306 INFO: checking COLLECT
19306 INFO: Building COLLECT because COLLECT-00.toc is non existent
19306 INFO: Building COLLECT COLLECT-00.toc
22581 INFO: Building COLLECT COLLECT-00.toc completed successfully.
62信息:PyInstaller:3.5
62信息:Python:3.7.5
62信息:平台:Windows-10-10.0.17763-SP0
62信息:编写了C:\Users\User\Desktop\Project\main.spec
62信息:UPX不可用。
62信息:使用路径扩展PYTHONPATH
['C:\\Users\\User\\Desktop\\Project',
'C:\\Users\\User\\Desktop\\Project']
62信息:检查分析
78信息:建筑分析,因为Analysis-00.toc不存在
78信息:正在初始化模块依赖关系图。。。
78信息:正在初始化模块图挂钩。。。
78信息:正在分析base_library.zip。。。
2124信息:运行分析-00.toc
2124信息:将Microsoft.Windows.Common-Controls添加到最终可执行文件的相关程序集
c:\users\user\appdata\local\programs\python\python37\python.exe所需
3900信息:缓存模块挂钩。。。
3900信息:分析C:\Users\User\Desktop\Project\main.py
4306信息:处理预查找模块路径挂钩区
5040信息:正在处理预查找模块路径挂钩站点
5040信息:站点:重新定位到伪目录'c:\\users\\user\\appdata\\local\\programs\\python\\python37\\lib\\site packages\\PyInstaller\\fake Module'
5925信息:处理预安全导入模块hook setuptools.extern.six.moves
7668信息:正在加载模块挂钩。。。
7668信息:加载模块挂钩“hook distutils.py”。。。
7671信息:加载模块钩子“hook encodings.py”。。。
7743信息:加载模块挂钩“hook-lib2to3.py”。。。
7747信息:加载模块挂钩“hook numpy.core.py”。。。
7845信息:加载模块挂钩“hook numpy.py”。。。
7846信息:加载模块hook“hook-pkg_resources.py”。。。
8092信息:正在处理预安全导入模块挂钩win32com
回溯(最近一次呼叫最后一次):
文件“”,第2行,在
ModuleNotFoundError:没有名为“win32com”的模块
8150信息:正在处理预安全导入模块挂钩win32com
回溯(最近一次呼叫最后一次):
文件“”,第2行,在
ModuleNotFoundError:没有名为“win32com”的模块
8327信息:加载模块钩子“hook pydoc.py”。。。
8328信息:加载模块钩子“hook setuptools.py”。。。
8742信息:正在加载模块挂钩“hook sysconfig.py”。。。
8742信息:正在加载模块钩子“hook xml.dom.domreg.py”。。。
8742信息:正在加载模块钩子“hook xml.py”。。。
8742信息:加载模块挂钩“挂钩-_tkinter.py”。。。
9133信息:正在检查树
9133信息:正在生成树,因为Tree-00.toc不存在
9148信息:构建Tree-00.toc
9211信息:正在检查树
9211信息:正在生成树,因为Tree-01.toc不存在
9211信息:构建Tree-01.toc
9258信息:正在查找ctypes DLL
9273信息:正在分析运行时挂钩。。。
9273信息:包括运行时钩子'pyi_rth_pkgres.py'
9289信息:包括运行时钩子'pyi\u rth\u multiprocessing.py'
9289信息:包括运行时钩子'pyi_rth_utkinter.py'
9289信息:查找动态库
18180信息:寻找鸡蛋
18180信息:使用Python库c:\users\user\appdata\local\programs\Python\python37\python37.dll
18180信息:找到绑定重定向:
[]
18180信息:写入C:\Users\User\Desktop\Project\build\main\warn-main.txt的警告
18445信息:图形交叉引用写入C:\Users\User\Desktop\Project\build\main\xref-main.html
18492信息:正在检查PYZ
18492信息:正在生成PYZ,因为PYZ-00.toc不存在
18492信息:构建PYZ(ZlibArchive)C:\Users\User\Desktop\Project\build\main\PYZ-00.PYZ
19259信息:生成PYZ(ZlibArchive)C:\Users\User\Desktop\Project\build\main\PYZ-00.PYZ已成功完成。
19274信息:检查包装
19274信息:正在生成PKG,因为PKG-00.toc不存在
19274信息:建筑包装(CArchive)包装-00.PKG
19290信息:已成功完成构建包(CArchive)PKG-00.PKG。
19290信息:引导加载程序c:\users\user\appdata\local\programs\python37\lib\site packages\PyInstaller\Bootloader\Windows-64bit\runw.exe
19290信息:正在检查EXE
19290信息:正在生成EXE,因为EXE-00.toc不存在
19290信息:从EXE-00.toc生成EXE
19290信息:将存档附加到EXE C:\Users\User\Desktop\Project\build\main\main.EXE
19306信息:从EXE-00.toc生成EXE已成功完成。
19306信息:支票到付
19306信息:正在生成COLLECT,因为COLLECT-00.toc不存在
19306信息:建筑物收集-00.toc
22581信息:已成功完成生成COLLECT-00.toc。
这里是错误


我怎样才能解决这个问题?你知道吗?

试着设置路径并包括所有必要的路径

setlocal
set PATH=C:\Python37;%PATH%

pyinstaller -y -D --name Your_program_name--paths "C:\Windows\System32\downlevel" --windowed -i C:\ICONS\AI-2.ico --clean --distpath="." -p "c:\Python34\Lib\site-packages\whatever_is_needed" main.py
我也总是将main.py重命名为main.pyw
如果仍然出现错误或什么都没有,请尝试从cmd运行*.exe,查看是否有任何错误显示。

已解决。

  • 安装
    pywin32
    以修复
    项目的
    venv\Lib\site packages
    文件夹中的
    ModuleNotFoundError:没有名为“win32com”的模块
  • 项目的
    venv\Lib\site packages
    文件夹中安装
    tornado
  • 打开终端并移动到项目文件夹
  • 运行
    setlocal

  • 运行
    set PATH=C:\Users\User\AppData\Local\Programs\Python\Python37\;%路径%
  • 运行
    pyinstaller-y-D--path“C:\Windows\System32\downlevel”--path“C:\Users\User\Desktop\Project\venv\Lib\site packages”main.py
  • images
    文件夹从
    Project
    复制到
    dist