Python PyInstaller未创建.exe文件

Python PyInstaller未创建.exe文件,python,python-3.x,windows-10,exe,pyinstaller,Python,Python 3.x,Windows 10,Exe,Pyinstaller,我正在尝试使用PyInstaller和脚本创建一个可执行文件。作为参考,我将Windows10与Python3.8.0和PyInstaller版本3.5一起使用 我的脚本名为hello_world.py,它保存在自己的文件夹中 print("Hello World!") 在命令提示下,我导航到hello_world.py所在的文件夹并运行: pyinstaller hello_world.py 这是输出: 46 INFO: PyInstaller: 3.5 46 INFO: Python:

我正在尝试使用PyInstaller和脚本创建一个可执行文件。作为参考,我将Windows10与Python3.8.0和PyInstaller版本3.5一起使用

我的脚本名为hello_world.py,它保存在自己的文件夹中

print("Hello World!")
在命令提示下,我导航到hello_world.py所在的文件夹并运行:

pyinstaller hello_world.py
这是输出:

46 INFO: PyInstaller: 3.5
46 INFO: Python: 3.8.0
46 INFO: Platform: Windows-10-10.0.17763-SP0
62 INFO: wrote F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.spec
78 INFO: UPX is not available.
78 INFO: Extending PYTHONPATH with paths
['F:\\Python\\Python Scripts\\Pyinstaller\\Py installer test',
 'F:\\Python\\Python Scripts\\Pyinstaller\\Py installer test']
78 INFO: checking Analysis
78 INFO: Building Analysis because Analysis-00.toc is non existent
78 INFO: Initializing module dependency graph...
93 INFO: Initializing module graph hooks...
93 INFO: Analyzing base_library.zip ...
3592 INFO: running Analysis Analysis-00.toc
3592 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\users\l&a\appdata\local\programs\python\python38\python.exe
4014 INFO: Caching module hooks...
4014 INFO: Analyzing F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.py
4045 INFO: Loading module hooks...
4045 INFO: Loading module hook "hook-encodings.py"...
4202 INFO: Loading module hook "hook-pydoc.py"...
4202 INFO: Loading module hook "hook-xml.py"...
4405 INFO: Looking for ctypes DLLs
4420 INFO: Analyzing run-time hooks ...
4420 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
4420 INFO: Looking for dynamic libraries
5592 INFO: Looking for eggs
5592 INFO: Using Python library c:\users\l&a\appdata\local\programs\python\python38\python38.dll
5592 INFO: Found binding redirects:
[]
5592 INFO: Warnings written to F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\warn-hello_world.txt
5670 INFO: Graph cross-reference written to F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\xref-hello_world.html
5686 INFO: checking PYZ
5686 INFO: Building PYZ because PYZ-00.toc is non existent
5686 INFO: Building PYZ (ZlibArchive) F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello_world\PYZ-00.pyz
Traceback (most recent call last):
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\L&A\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe\__main__.py", line 7, in <module>
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 111, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\__main__.py", line 63, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 844, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\build_main.py", line 791, in build
    exec(code, spec_namespace)
  File "F:\Python\Python Scripts\Pyinstaller\Py installer test\hello_world.spec", line 18, in <module>
    pyz = PYZ(a.pure, a.zipped_data,
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 98, in __init__
    self.__postinit__()
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\datastruct.py", line 158, in __postinit__
    self.assemble()
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 128, in assemble
    self.code_dict = {
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\api.py", line 129, in <dictcomp>
    key: strip_paths_in_code(code)
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 652, in strip_paths_in_code
    consts = tuple(
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 653, in <genexpr>
    strip_paths_in_code(const_co, new_filename)
  File "c:\users\l&a\appdata\local\programs\python\python38\lib\site-packages\PyInstaller\building\utils.py", line 660, in strip_paths_in_code
    return code_func(co.co_argcount, co.co_kwonlyargcount, co.co_nlocals, co.co_stacksize,
TypeError: an integer is required (got type bytes)
46信息:PyInstaller:3.5
46信息:Python:3.8.0
46信息:平台:Windows-10-10.0.17763-SP0
62信息:编写了F:\Python\Python Scripts\Pyinstaller\Py installer test\hello\u world.spec
78信息:UPX不可用。
78信息:使用路径扩展PYTHONPATH
['F:\\Python\\Python Scripts\\Pyinstaller\\Py installer test',
'F:\\Python\\Python脚本\\Pyinstaller\\Py安装程序测试']
78信息:检查分析
78信息:建筑分析,因为Analysis-00.toc不存在
78信息:正在初始化模块依赖关系图。。。
93信息:正在初始化模块图挂钩。。。
93信息:正在分析base_library.zip。。。
3592信息:运行分析-00.toc
3592信息:将Microsoft.Windows.Common-Controls添加到最终可执行文件的相关程序集
c:\users\l&a\appdata\local\programs\python\python38\python.exe所需
4014信息:缓存模块挂钩。。。
4014信息:分析F:\Python\Python Scripts\Pyinstaller\Py installer test\hello\u world.Py
4045信息:正在加载模块挂钩。。。
4045信息:加载模块钩子“hook encodings.py”。。。
4202信息:加载模块钩子“hook pydoc.py”。。。
4202信息:正在加载模块钩子“hook xml.py”。。。
4405信息:正在查找ctypes DLL
4420信息:正在分析运行时挂钩。。。
4420信息:包括运行时钩子'pyi\u rth\u multiprocessing.py'
4420信息:寻找动态库
5592信息:寻找鸡蛋
5592信息:使用Python库c:\users\l&a\appdata\local\programs\Python\python38\python38.dll
5592信息:找到绑定重定向:
[]
5592信息:写入F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello\u world\warn-hello\u world.txt的警告
5670信息:写入F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello\u world\xref-hello\u world.html的图形交叉引用
5686信息:正在检查PYZ
5686信息:正在生成PYZ,因为PYZ-00.toc不存在
5686信息:构建PYZ(ZlibArchive)F:\Python\Python Scripts\Pyinstaller\Py installer test\build\hello\u world\PYZ-00.PYZ
回溯(最近一次呼叫最后一次):
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py”,第192行,位于\u run\u模块\u as\u main中
返回运行代码(代码、主全局、无、,
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\runpy.py”,第85行,在运行代码中
exec(代码、运行\全局)
文件“C:\Users\L&A\AppData\Local\Programs\Python\Python38\Scripts\pyinstaller.exe \\uuuuuu main\uuuuuuuuu.py”,第7行,在
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\site packages\PyInstaller\\uuuuuuu main\uuuuuuuu.py”,第111行,正在运行
运行构建(pyi\u配置,规范文件,**vars(args))
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\site packages\PyInstaller\uuuuuu main\uuuuuuuuuu.py”,第63行,在run\u build中
PyInstaller.building.build\u main.main(pyi\u配置,spec\u文件,**kwargs)
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\site packages\PyInstaller\building\build\u main.py”,第844行,在main中
构建(specfile,kw.get('distpath'),kw.get('workpath'),kw.get('clean_build'))
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\site packages\PyInstaller\building\build\u main.py”,第791行,内部版本
exec(代码、规范和命名空间)
文件“F:\Python\Python Scripts\Pyinstaller\Py installer test\hello\u world.spec”,第18行,在
pyz=pyz(a.pure,a.zipped_数据,
文件“c:\users\l&a\appdata\local\programs\python38\lib\site packages\PyInstaller\building\api.py”,第98行,在uu init中__
self.\uuuu postinit\uuuuu()
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\site packages\PyInstaller\building\datastruct.py”,第158行,在u postinit中__
self.assembly()
汇编文件“c:\users\l&a\appdata\local\programs\python38\lib\site packages\PyInstaller\building\api.py”第128行
self.code_dict={
文件“c:\users\l&a\appdata\local\programs\python38\lib\site packages\PyInstaller\building\api.py”,第129行,在
关键字:代码中的条带路径(代码)
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\site packages\PyInstaller\building\utils.py”,第652行,在代码中的条带路径中
常量=元组(
文件“c:\users\l&a\appdata\local\programs\python\38\lib\site packages\PyInstaller\building\utils.py”,第653行,在
代码中的条带路径(常量,新文件名)
文件“c:\users\l&a\appdata\local\programs\python\python38\lib\site packages\PyInstaller\building\utils.py”,第660行,位于代码中的条带路径中
返回代码_func(co.co_argcount、co.co_kwonlyargcount、co.co_nlocals、co.co_stacksize、,
TypeError:需要整数(获取类型字节)

这将创建名为“dist”和“build”的文件夹以及名为“hello\u world.spec”的文件,但“dist”文件夹是空的。发生了什么问题?

我过去遇到过这个问题,请执行以下操作: 根据示例spyder或Atom terminal打开Anaconda prompt或任何其他IDE,以管理员身份打开命令行,导航到.py所在的文件夹,并按如下方式运行命令:

在我的示例中,我要编译的文件是getwindowsversion.py

这将创建一个独立的。exe可以使用

pyinstaller--onefile getwindowsversion.py

如果要创建常规生成


pyinstaller getwindowsversion.py

我以前遇到过这个问题,您能执行以下操作吗: 根据示例spyder或Atom terminal打开Anaconda prompt或任何其他IDE,以管理员身份打开命令行,导航到.py所在的文件夹,并按如下方式运行命令:

在我的示例中,我要编译的文件是getwindowsversion.py

这将创建一个独立的。exe可以使用