为Python 2.7创建可执行文件,获取RuntimeError:最大递归深度

时间:2015-09-17 16:11:28

标签: python python-2.7 recursion runtime-error py2exe

我正在运行Python 2.7。我下载py2exe版本0.6.9 win32从我的.py文件创建一个可执行文件。我知道它是旧版本,因此我不确定是否会造成错误。

我已经完成了以下步骤:创建一个setup.py文件:

from distutils.core import setup
import py2exe
setup(console=["MyFileName.py"])

然后从命令窗口运行python setup.py py2exe --help,然后python setup.py py2exe

然而,它出现了

RuntimeError: maximum recursion depth exceeded while calling a Python object.

我知道当代码遇到无限递归时会发生这种情况,但我的.py文件没有出现此错误,所以我不知道它来自何处。我尝试添加

import sys
sys.setrecursionlimit(5000)

基于另一个StackOverflow答案,但我仍然得到相同的错误。

我很乐意提供相关信息以帮助排除故障,但我不确定哪些内容会有所帮助。使用py2exe以外的其他工具如PyInstaller或cxfreeze会更好还是可能遇到同样的错误?

编辑:

这是追溯,我似乎无法从头开始获取它,但这是在我的命令提示符下显示的内容。

    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 456, in scan_code
    self.scan_code(c, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 456, in scan_code
    self.scan_code(c, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 456, in scan_code
    self.scan_code(c, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 343, in _safe_import_h
ook
    self.import_hook(name, caller, [sub], level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 141, in import_hook
    self.ensure_fromlist(m, fromlist)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 231, in ensure_fromlis
t
    submod = self.import_module(sub, subname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 295, in load_module
    m = self.load_package(fqname, pathname)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 471, in load_package
    self.load_module(fqname, fp, buf, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 446, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 136, in import_hook
    q, tail = self.find_head_package(parent, name)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 192, in find_head_pack
age
    q = self.import_module(head, qname, parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 456, in scan_code
    self.scan_code(c, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 295, in load_module
    m = self.load_package(fqname, pathname)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 471, in load_package
    self.load_module(fqname, fp, buf, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 449, in scan_code
    self._safe_import_hook(parent.__name__, None, fromlist, level=0)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 343, in _safe_import_h
ook
    self.import_hook(name, caller, [sub], level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 141, in import_hook
    self.ensure_fromlist(m, fromlist)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 231, in ensure_fromlis
t
    submod = self.import_module(sub, subname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 295, in load_module
    m = self.load_package(fqname, pathname)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 471, in load_package
    self.load_module(fqname, fp, buf, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 456, in scan_code
    self.scan_code(c, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 136, in import_hook
    q, tail = self.find_head_package(parent, name)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 199, in find_head_pack
age
    q = self.import_module(head, qname, parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 295, in load_module
    m = self.load_package(fqname, pathname)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 471, in load_package
    self.load_module(fqname, fp, buf, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 343, in _safe_import_h
ook
    self.import_hook(name, caller, [sub], level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 141, in import_hook
    self.ensure_fromlist(m, fromlist)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 231, in ensure_fromlis
t
    submod = self.import_module(sub, subname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 295, in load_module
    m = self.load_package(fqname, pathname)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 471, in load_package
    self.load_module(fqname, fp, buf, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 314, in load_module
    self.scan_code(co, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 423, in scan_code
    self._safe_import_hook(name, m, fromlist, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 332, in _safe_import_h
ook
    self.import_hook(name, caller, level=level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 719, in import_hook
    return Base.import_hook(self,name,caller,fromlist,level)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 137, in import_hook
    m = self.load_tail(q, tail)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 214, in load_tail
    m = self.import_module(head, mname, m)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 724, in import_module
    r = Base.import_module(self,partnam,fqname,parent)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 284, in import_module
    m = self.load_module(fqname, fp, pathname, stuff)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 730, in load_module
    r = Base.load_module(self, fqname, fp, pathname, (suffix, mode, typ))
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 295, in load_module
    m = self.load_package(fqname, pathname)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 463, in load_package
    m = self.add_module(fqname)
  File "C:\Anaconda\lib\site-packages\py2exe\mf.py", line 478, in add_module
    self.modules[fqname] = m = Module(fqname)
RuntimeError: maximum recursion depth exceeded while calling a Python object

如果我尝试使用Pyinstaller运行它,我会收到错误TypeError: iteration over non-sequence,这似乎与使用py2exe的错误有关。

在MyFileName.py中的

我导入以下模块:

import __future__    
#from __future__ import division
import itertools
from Tkinter import *
import numpy as np
from collections import OrderedDict
from bokeh.plotting import ColumnDataSource, figure, show, output_file
from bokeh.models import HoverTool
import pandas as pd
import datetime as datetime
import pandas.util.testing as tm; tm.N = 3
import pyodbc
import csv
from bokeh.charts import Bar
from bokeh.palettes import RdYlGn11
import calendar
import dateutil

0 个答案:

没有答案