【问题标题】:Generated standalone *.exe from python is not runnable从 python 生成的独立 *.exe 不可运行
【发布时间】:2020-10-06 01:13:14
【问题描述】:

虽然通过命令“pyinstaller --onefile filename.py”可以成功完成从*.py-到独立的*.exe文件的转换,但可执行文件本身无法运行

Traceback(最近一次调用最后一次):文件 "venv\Lib\site-packages\PyInstaller\loader\rthooks\pyi_rth_pkgres.py", 第 13 行,在文件中 "c:\users\user01\pycharmprojects\api4trd\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", 第 623 行,在 exec_module 中 exec(bytecode, module.dict) 文件“lib\site-packages\pkg_resources__init__.py”,第 86 行,在 ModuleNotFoundError:没有名为“pkg_resources.py2_warn”的模块 [13560] 执行脚本pyi_rth_pkgres失败

使用以下包

1) 数学

2) 日期时间

3) yfinance

Python 版本:3.8.1

pyinstaller 版本:3.6

操作系统:W10

谢谢!

【问题讨论】:

    标签: python exe pyinstaller


    【解决方案1】:

    您的 pyinstaller 命令中缺少一个隐藏的导入。虽然早期版本的 Python 和 Pyinstaller 从来没有出现过这个错误,但是这里是解决方案

    pyinstaller --onefile --hidden-import=pkg_resources.py2_warn filename.py
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      • 2017-03-07
      • 2018-04-10
      • 1970-01-01
      相关资源
      最近更新 更多