py2exe fails with pandas import

南楼画角 提交于 2019-12-02 11:27:35

问题


I have a python script that I want to make into an executable using py2exe. It fails when I try to import pandas (this is literally all I have in my example failing script):

import pandas

The traceback looks like:

File "c:\users\***\appdata\local\enthought\canopy\user\lib\site_packages\py2exe\mf.py", line 724, in import_hook return Base.import_hook(self,name,caller,fromlist,level)
RuntimeError: maximum recursion depth exceeded

I suspect that the problem may have something to do with the Canopy Python distribution, but I don't have an easy alternative to test.

Here is my setup file:

distutils.core.setup(
    options = {
        "py2exe": {
            "includes": ["pandas", "scipy"],
            "packages": ["matplotlib", "pytz"],
            "dll_excludes": ["MSVCP90.dll", ....],
        }
    }
    data_files=matplotlib.get_py2exe_datafiles(),
    windows=['just_pandas.py']
)

I have two questions. 1) Is there a way that I can make the pandas import work with py2exe? 2) If I can't fix this using the Canopy Python distribution, any suggestions for an alternative Python installation for Windows?


回答1:


It turns out that the solution is just resetting the recursion limit. So I added these lines to my setup.py file:

import sys
sys.setrecursionlimit(3000)

Now the pandas import works just fine.



来源:https://stackoverflow.com/questions/34229722/py2exe-fails-with-pandas-import

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!