我正在用cx_Freeze编写一个可执行程序。这个程序使用了几个库,如matplotlib和scipy。当我用我的“www.example.com”创建可执行文件时setup.py,我得到这个错误:RecursionError: maximum recursion depth exceeded during compilation
然后我运行了几个测试来找出哪个库导致了这个问题,结果是numpy。当我从setup.py中排除numpy时,创建了可执行文件,但当我运行它时,我得到一个错误,告诉我numpy尚未导入,因为matplotlib和scipy使用它。下面是我的setup.py:
import sys
from cx_Freeze import setup, Executable
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {
"includes": ["tkinter", "matplotlib", "pyvisa", "PIL", "cmath", "sympy", "scipy"],
# "excludes": ["numpy"],
"zip_include_packages": ["encodings", "PySide6", "numpy"],
}
# base="Win32GUI" should be used only for Windows GUI app
base = "Win32GUI" if sys.platform == "win32" else None
setup(
name="App",
version="0.1",
description="Software",
options={"build_exe": build_exe_options},
executables=[Executable("main.py", base=base, icon="icon.ico")],
)
我尝试手动导入numpy,但我不知道如何。有没有办法增加可能的递归的数量,比如pyinstaller和.spec?
1条答案
按热度按时间y53ybaqx1#
我刚刚找到了解决问题的办法。我尝试增加可能的递归数,就像使用pyinstaller的.spec.通过在“www.example.com”文件中添加完全相同的代码行setup.py,我可以创建我的可执行文件,并且我不再有任何兼容性问题。下面是我的工作代码: