iza
iza

Reputation: 117

Exe built with cx_freeze produces "module not found" errors for required package

I made a twitter bot using Python which uses the tweepy module. I then converted the Python file into an .exe file using cx_Freeze, following these instructions. If I run the program in Powershell as the Python file it all works but when I try to run the .exe file in command prompt I get the error below:

 Traceback (most recent call last):
 File "C:\Python36\lib\site-packages\cx_Freeze\initscripts\__startup__.py", 
 line 14, in run module.run()
 File "C:\Python36\lib\site-packages\cx_Freeze\initscripts\Console.py", line 
 26, in run
exec(code, m.__dict__)
File "twitterbot_retweet_recent_tweets_2.py", line 1, in <module>
ModuleNotFoundError: No module named 'tweepy'

I've already tried uninstalling and reinstalling tweepy again but I keep on getting the same error. Does anyone know how to fix this?

Upvotes: 1

Views: 748

Answers (1)

Doug Coburn
Doug Coburn

Reputation: 2575

Sometimes automatic dependency detection doesn't work. Add missing package dependencies to your build_exe options in your setup.py

# Add tweepy, queue here
packages = ["idna", "tweepy", "queue"]
options = {
    'build_exe': {
        'packages':packages,
    },
}

Upvotes: 1

Related Questions