2016-08-16 165 views
1

我使用pyinstaller 3.2(通過pip install pyinstaller獲取)運行WinPython 3.4.4.3。pyinstaller創建EXE RuntimeError:調用Python對象時超出最大遞歸深度

現在我已經有一些非常簡單的Qt4代碼,我想轉換爲EXE,並且遇到了無法解決的問題。

驗證碼:

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和我越來越:

RuntimeError: maximum recursion depth exceeded while calling a Python object 

現在,如果有,我發現,也影響了問題的幾件事:

1)如果我註釋掉這一行:from scipy.interpolate import InterpolatedUnivariateSpline

2)從使用Scipy.Interpolate(RBS,但仍然)的另一個不同腳本創建EXE文件 - 像魅力一樣工作。 3)如果我嘗試使用WinPython 3.5.1.1 + pyinstaller將其轉換爲EXE,並且它是相同的3.2版本 - 它生成我的exe文件沒有問題。

我想了解是什麼原因造成的錯誤,我不能找到谷歌任何答案不幸的是,我可以找到的大多數修復與matplotlib相關,而不是插值。

+0

你有沒有解決這個問題? – Eoin

回答

1

我想嘗試增加遞歸深度限制。在你的文件的開頭插入:

import sys 
sys.setrecursionlimit(5000) 
+0

是否做到了。沒有幫助。 –

1

穆斯塔法的確引導我走向正確的方向,你必須增加遞歸限制。但是,代碼必須付諸規範文件的開頭,而不是在你的Python代碼:

# -*- mode: python -*- 
import sys 
sys.setrecursionlimit(5000) 

pyi-makespec首先創建規範文件,編輯它,然後在規範文件傳遞到pyinstaller命令建立。有關using spec files的更多信息,請參閱pyinstaller手冊。

請務必使用pyinstaller 3.2.0,3.2.1你會得到ImportError: cannot import name 'is_module_satisfies'(見GitHub上的issue

相關問題