我在pycharm中将python脚本编码为“probe.py”,然后使用setup.py文件中提到的代码构建可执行(.exe)文件,但是这样创建的exe文件在打开时显示错误 导入错误mising需要依赖['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)])
`
答案 0 :(得分: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)]
)
运行此脚本告诉我是否存在问题
答案 1 :(得分:0)
根据cx_Freeze documentation,尝试使用包密钥添加build_exe。