python – 使用py2exe打包py文件时“超出最大递归深度”

前端之家收集整理的这篇文章主要介绍了python – 使用py2exe打包py文件时“超出最大递归深度”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

几个月前py2exe在同一个py文件上工作得很好.但是当我今天再次尝试它时,通过报告“RuntimeError:超出最大递归深度”失败了.结果我得到一个空的“dist”文件夹.
Py文件正常工作,它无法打包.我猜py文件中导入的模块有问题.但我无法弄明白.有人知道解决方案吗?

我的py文件的开头部分是:

import xlrd
import wx
import wx.lib.filebrowsebutton as filebrowse
from scipy.optimize import fsolve
import math
import threading
from sympy import Symbol
from sympy import solve

cmd窗口的最后几行是:

File "D:\Python27\lib\site-packages\py2exe\mf.py",line 332,in _safe_import_hook
self.import_hook(name,caller,level=level)
File "D:\Python27\lib\site-packages\py2exe\mf.py",line 719,in import_hook
return Base.import_hook(self,name,fromlist,level)
File "D:\Python27\lib\site-packages\py2exe\mf.py",line 137,in import_hook
m = self.load_tail(q,tail)
File "D:\Python27\lib\site-packages\py2exe\mf.py",line 214,in load_tail
m = self.import_module(head,mname,m)
File "D:\Python27\lib\site-packages\py2exe\mf.py",line 724,in import_module
r = Base.import_module(self,partnam,fqname,parent)
File "D:\Python27\lib\site-packages\py2exe\mf.py",line 284,in import_module
m = self.load_module(fqname,fp,pathname,stuff)
File "D:\Python27\lib\site-packages\py2exe\mf.py",line 730,in load_module
r = Base.load_module(self,(suffix,mode,typ))
File "D:\Python27\lib\site-packages\py2exe\mf.py",line 314,in load_module
self.scan_code(co,line 423,in scan_code
self._safe_import_hook(name,m,line 134,in import_hook
self.msg(3,"import_hook",level)
RuntimeError: maximum recursion depth exceeded

D:\Python27\py2exetemp>pause
最佳答案
我试着增加递归深度限制.在文件的开头插入:

import sys
sys.setrecursionlimit(5000)
原文链接:https://www.f2er.com/python/439150.html

猜你在找的Python相关文章