Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
140 views
in Technique[技术] by (71.8m points)

python - Py2exe, Runtimeerror with tweepy

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:Python34libsite-packagespy2exehooks.py", line 291, in __getattr__
    self.__finder.safe_import_hook(renamed, caller=self)
  File "C:Python34libsite-packagespy2exemf3.py", line 138, in safe_import_hook
    self.import_hook(name, caller, fromlist, level)
  File "C:Python34libsite-packagespy2exemf3.py", line 120, in import_hook
    module = self._gcd_import(name)
  File "C:Python34libsite-packagespy2exemf3.py", line 274, in _gcd_import
    return self._find_and_load(name)
  File "C:Python34libsite-packagespy2exemf3.py", line 298, in _find_and_load
    getattr(parent_module, name.rpartition('.')[2])

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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"]
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...