Py2exe, Runtimeerror with tweepy

…衆ロ難τιáo~ 提交于 2020-01-09 08:05:00

问题


I wanted to use the python plugin for twitter called tweepy.

in my main.py file I just imported tweepy

import tweepy

My setup-file looks like this:

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

When i execute python setupy.py py2exe via command line I get this repeating codeblock until I get an 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])

Does anyone knows a way to break out of this cycle?


回答1:


There seems to be a bug in the 0.9.2.2 version of py2exe where the module six.moves.urllib.parse gets into an infinite recursion loop until it reaches the maximum depth.

One way to go around it, if you don't really need the module, is to exclude the module in your setup.py:

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


来源:https://stackoverflow.com/questions/29649440/py2exe-runtimeerror-with-tweepy

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