【问题标题】:error in creating executable file from python从python创建可执行文件时出错
【发布时间】:2018-11-21 20:47:04
【问题描述】:

我在 pycharm 中将 python 脚本编码为“probe.py”,然后使用 setup.py 文件中提到的代码从中构建了可执行(.exe)文件,但是这样创建的 exe 文件在打开时显示错误 导入错误缺少所需的依赖项['numpy'],即使它存在于我的项目中。

错误图片

  import sys

  from cx_Freeze import setup,Executable


  include_files = ['autorun.inf']
  base = None

  if sys.platform == "win32":
  base = "Win32GUI"

  setup(name="Probe",version="0.1",description="fun",
  options={'build_exe':{'include_files': include_files}},
  executables=[Executable("probe.py",base=base)])

`

【问题讨论】:

  • 你有什么错误?你也可以发一下吗?
  • @Nihal 我添加了一张图片作为错误对话框的描述。谢谢!
  • 请不要发布图片,除非是 GUI 问题,请将错误文本复制并粘贴到您的问题中。
  • 如何复制粘贴窗口错误弹出消息?

标签: python winforms numpy pycharm pyinstaller


【解决方案1】:
from cx_Freeze import setup, Executable
   base = None
   if sys.platform == "win32":
     base = "Win32GUI"
   build_exe_options = {"packages": ["numpy"],
     include_files = ['autorun.inf']}

   setup(
        name = "Probe",
        version = "0.1",
        description = "fun",
        options = {"build_exe": build_exe_options},
        executables = [Executable("probe.py",base=base)]
        )

运行这个脚本告诉我是否有问题

【讨论】:

  • 很高兴能帮到你
【解决方案2】:

根据cx_Freeze documentation,尝试添加带有包密钥的build_exe。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-13
    • 2013-04-09
    • 2017-09-14
    • 2016-12-20
    • 1970-01-01
    • 1970-01-01
    • 2019-07-14
    相关资源
    最近更新 更多