【问题标题】:Py2exe, Runtimeerror with tweepyPy2exe,带有 tweepy 的运行时错误
【发布时间】:2015-06-21 08:49:12
【问题描述】:

我想为 twitter 使用名为 tweepy 的 python 插件。

在我的 main.py 文件中,我刚刚导入了 tweepy

import tweepy

我的安装文件如下所示:

from distutils.core import setup
import py2exe
setup(
    windows=[{
        "script": 'main.py',
        }],
    options={
        "py2exe": {
            "includes": ["sip", "tweepy"]
        }
    }
)

当我通过命令行执行 python setupy.py py2exe 时,我得到这个重复的代码块,直到我得到一个 RuntimeError: maximum recursion depth exceeded in comparison。

File "C:\Python34\lib\site-packages\py2exe\hooks.py", line 291, in __getattr__
    self.__finder.safe_import_hook(renamed, caller=self)
  File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 138, in safe_import_hook
    self.import_hook(name, caller, fromlist, level)
  File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 120, in import_hook
    module = self._gcd_import(name)
  File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 274, in _gcd_import
    return self._find_and_load(name)
  File "C:\Python34\lib\site-packages\py2exe\mf3.py", line 298, in _find_and_load
    getattr(parent_module, name.rpartition('.')[2])

有没有人知道打破这个循环的方法?

【问题讨论】:

    标签: python py2exe tweepy


    【解决方案1】:

    There seems to be a bug 在 py2exe 的 0.9.2.2 版本中,其中模块 six.moves.urllib.parse 进入无限递归循环,直到达到最大深度。

    绕过它的一种方法是,如果您真的不需要该模块,则在您的 setup.py 中排除该模块:

    options={
        "py2exe": {
            "includes": ["sip", "tweepy"],
            "excludes": ["six.moves.urllib.parse"]
        }
    }
    

    【讨论】:

    • 我现在使用了一个类似的 twitter 插件。但我检查了你的解决方案,它有效,谢谢
    猜你喜欢
    • 1970-01-01
    • 2014-04-04
    • 1970-01-01
    • 2017-04-12
    • 1970-01-01
    • 1970-01-01
    • 2015-06-25
    • 2013-11-15
    • 1970-01-01
    相关资源
    最近更新 更多