Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
568 views
in Technique[技术] by (71.8m points)

pyinstaller creating EXE RuntimeError: maximum recursion depth exceeded while calling a Python object

I am running WinPython 3.4.4.3 with pyinstaller 3.2 (obtained via pip install pyinstaller).

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.

The Code:

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()

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) If I comment out this line: from scipy.interpolate import InterpolatedUnivariateSpline

2) Creating EXE file from another different script that uses Scipy.Interpolate (RBS, but still) - works like a charm.

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This worked for me

  1. Run pyinstaller and stop it to generate the spec file :

    pyinstaller filename.py
    

    A file with .spec as extension should be generated

  2. Now add the following lines to the beginning of the spec file :

    import sys
    sys.setrecursionlimit(5000)
    
  3. Now run the spec file using :

    pyinstaller filename.spec
    

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...