Search code examples
pythoncompilationpy2exetweepysetup.py

Py2exe; Import Error no module named Tweepy


My python script includes a Qt GUI which I'm trying to convert into a Windows executable using Py2exe. My script is using the Tweepy module to fetch data from Twitter. So I include Tweepy and try to compile it into an executable using the following Setup.py:

from distutils.core import setup
import py2exe

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

The following Error gets raised:

raise ImportError, "No module named " + qname
ImportError: No module named tweepy

I've succesfully used the same setup file (minus the 'Tweepy include') to compile other script in the past. What am I missing here?


Solution

  • Assuming that you have tweepy installed in the python installation that you are trying to build with try adding:

    import tweepy
    

    near the start of your setup.py to ensure that py2exe can really see it, some packages do some interesting things during import.