【问题标题】:Python Py to EXEPython Py 转 EXE
【发布时间】:2020-03-28 06:17:06
【问题描述】:

试图弄清楚为什么 Pyinstaller 没有在 \Dist 文件夹中生成 .EXE。

我正在运行的是pyinstaller --onefile FileName.py

但在此之后它失败了:

7758 INFO: Building PYZ (ZlibArchive) 发生错误,回溯如下: 回溯(最近一次通话最后): 转换中的文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\auto_py_to_exe__main__.py”,第 269 行 pyi.run() # 执行 PyInstaller 运行中的文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller__main__.py”,第 111 行 run_build(pyi_config, spec_file, **vars(args)) 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller__main__.py”,第 63 行,在 run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py”,第 844 行,在 main 构建(规范文件,kw.get('distpath'),kw.get('工作路径'),kw.get('clean_build')) 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\build_main.py”,第 791 行,在构建中 执行(代码,规范命名空间) 文件“C:\Users\Marcu\AppData\Local\Temp\tmp2gf7vp4s\File_Rename.spec”,第 18 行,在 pyz = PYZ(a.pure, a.zipped_data, init 中的文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py”,第 98 行 self.postinit() postinit 中的文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\datastruct.py”,第 158 行 self.assemble() 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py”,第 128 行,在 assemble self.code_dict = { 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\api.py”,第 129 行,在 键:strip_paths_in_code(代码) 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py”,第 652 行,在 strip_paths_in_code 常量 = 元组( 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py”,第 653 行,在 strip_paths_in_code(const_co, new_filename) 文件“c:\users\marcu\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\building\utils.py”,第 660 行,在 strip_paths_in_code 返回 code_func(co.co_argcount,co.co_kwonlyargcount,co.co_nlocals,co.co_stacksize, TypeError:需要一个整数(获取类型字节)

等等。

  • 路径已设置
  • 最新版本
  • 脚本在通过 Python 运行时按预期工作

这个想法是让 .py 成为 .exe,这样我就可以在没有 Python 的计算机上运行它。

【问题讨论】:

  • 您可能想考虑为您的项目创建一个虚拟环境,然后尝试安装它。我想你在你的问题中用正楷写了PyinstallerP,应该是p。我猜那是你打错了。
  • 嗨。我确实尝试过使用虚拟环境,但似乎最终结果是一样的。是的,我用“P”做了一个类型,谢谢你的注意。
  • 不使用 --onefile 时的行为有什么不同吗?也许这可以帮助指导原因。另外,看起来您没有复制整个消息,您复制的部分显示“INFO”,而不是错误?
  • 是的,我没有复制完整的错误,因为它非常长。并且不离开 --onefile 不会改变任何东西。我将其编辑为完整的错误。

标签: python pip exe pyinstaller


【解决方案1】:

我找到了答案。

通过使用pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

它卸载了 3.5 版并安装了 4.0 开发版。

使用 pyinstaller xxxx.py 和瞧

感谢大家的参与

【讨论】:

    猜你喜欢
    • 2020-11-06
    • 2020-09-22
    • 2018-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多