pyinstaller 创建 EXE 运行时错误:调用 Python 对象时超出了最大递归深度 [英] pyinstaller creating EXE RuntimeError: maximum recursion depth exceeded while calling a Python object
问题描述
我正在使用 pyinstaller 3.2 运行 WinPython 3.4.4.3(通过 pip install pyinstaller 获得).
I am running WinPython 3.4.4.3 with pyinstaller 3.2 (obtained via pip install pyinstaller).
现在我有一些非常简单的 Qt4 代码,我想将其转换为 EXE,但我遇到了无法解决的问题.
Now I've got some really simple Qt4 code that I want to convert to EXE and I've run into problem that I cannot solve.
代码:
import sys
import math
from PyQt4 import QtGui, QtCore
import SMui
import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline
class SomeCalculation(QtGui.QMainWindow, SMui.Ui_MainWindow):
def __init__(self):
super(self.__class__, self).__init__()
self.setupUi(self)
self.setWindowTitle('Some Calculation')
self.calculate.clicked.connect(self.some_math)
def some_math(self):
a_diameter=self.a_diameter.value()
b_diameter=self.b_diameter.value()
complement=self.complement.value()
angle=self.angle.value()
preload=self.preload.value()
### ONLY MATH HAPPENS HERE also defining X and Y ####
interpolator = InterpolatedUnivariateSpline(X, Y)
### MORE MATH HAPPENS HERE ####
self.axial.setText(str(axial))
self.radial.setText(str(radial))
def main():
app = QtGui.QApplication(sys.argv)
window=SomeCalculation()
window.show()
app.exec_()
if __name__=='__main__':
main()
我尝试运行 pyinstaller file_name.py
并且我得到:
I try to run pyinstaller file_name.py
and I'm getting:
RuntimeError: maximum recursion depth exceeded while calling a Python object
现在,如果我发现了一些也会影响问题的事情:
Now if there's a few things that I have found out that also affect the issue:
1) 如果我注释掉这一行:from scipy.interpolate import InterpolatedUnivariateSpline
1) If I comment out this line: from scipy.interpolate import InterpolatedUnivariateSpline
2) 从另一个使用 Scipy.Interpolate(RBS,但仍然)的不同脚本创建 EXE 文件 - 就像一个魅力.
2) Creating EXE file from another different script that uses Scipy.Interpolate (RBS, but still) - works like a charm.
3) 如果我尝试使用以相同方式获得的 WinPython 3.5.1.1 + pyinstaller 将其转换为 EXE,并且它是相同的 3.2 版本 - 它生成我的 exe 文件没有问题.
3) If I try to convert it to EXE using WinPython 3.5.1.1 + pyinstaller obtained the same way, and it's the same 3.2 version of it - it generates my exe file no problems.
我想了解是什么导致了原始案例中的错误,不幸的是我在谷歌上找不到任何答案,但我能找到的大多数修复都与 matplotlib 相关,而不是插值.
I want to understand what's causing the error in the original case and I cannot find any answer on google unfortunately, most of the fixes I could find were related with matplotlib and not interpolation though.
推荐答案
这对我有用
运行 pyinstaller 并停止它以生成规范文件:
Run pyinstaller and stop it to generate the spec file :
pyinstaller filename.py
应该生成一个以.spec
为扩展名的文件
A file with .spec
as extension should be generated
现在将以下行添加到规范文件的开头:
Now add the following lines to the beginning of the spec file :
import sys
sys.setrecursionlimit(5000)
现在使用以下命令运行规范文件:
Now run the spec file using :
pyinstaller filename.spec
这篇关于pyinstaller 创建 EXE 运行时错误:调用 Python 对象时超出了最大递归深度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!