py2exe 因导入 pandas 而失败 [英] py2exe fails with pandas import

查看:72
本文介绍了py2exe 因导入 pandas 而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 python 脚本,我想使用 py2exe 将其制作成可执行文件.当我尝试导入熊猫时它失败了(这就是我在示例失败脚本中所拥有的所有内容):

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

回溯看起来像:

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

我怀疑这个问题可能与 Canopy Python 发行版有关,但我没有一个简单的替代方法来测试.

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.

这是我的安装文件:

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']
)

我有两个问题.1) 有没有办法让 Pandas 导入与 py2exe 一起工作?2)如果我不能使用 Canopy Python 发行版解决这个问题,有没有关于 Windows 的替代 Python 安装的建议?

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?

推荐答案

事实证明,解决方案只是重置递归限制.所以我将这些行添加到我的 setup.py 文件中:

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.

这篇关于py2exe 因导入 pandas 而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆