Import error with py2exe

Thread Solved

Join Date: May 2008
Posts: 902
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 145
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Import error with py2exe

 
0
  #1
Dec 5th, 2008
Hi guys,
I was making a program yesterday that would send an email using the email modules of python as well as the smtp module.
My problem is when i put it into an exe using py2exe and vega's code snippet setup i get some problems. This is the error message i get when i try and run the .exe file:
Traceback (most recent call last):
File "email_program.py", line 2, in <module>
File "email\__init__.pyc", line 79, in __getattr__
ImportError: No module named multipart
The thing is that is works fine when i run it when it is not compiled into an exe. Im not that crash hot with py2exe so i was wondering is someone with a bit more idea with me could point me in the right direction. Here is my code for any reference.
  1. import smtplib
  2. from email.MIMEMultipart import MIMEMultipart
  3. from email.MIMEBase import MIMEBase
  4. from email.MIMEText import MIMEText
  5. from email import Encoders
  6. import pythoncom, pyHook
  7. import os
  8. global s
  9. s = ""
  10. gmail_user = "*************"
  11. gmail_pwd = "************"
  12.  
  13. def mail(to, subject, text):
  14. msg = MIMEMultipart()
  15.  
  16. msg['From'] = gmail_user
  17. msg['To'] = to
  18. msg['Subject'] = subject
  19.  
  20. msg.attach(MIMEText(text))
  21.  
  22.  
  23. mailServer = smtplib.SMTP("smtp.gmail.com", 587)
  24. mailServer.ehlo()
  25. mailServer.starttls()
  26. mailServer.ehlo()
  27. mailServer.login(gmail_user, gmail_pwd)
  28. mailServer.sendmail(gmail_user, to, msg.as_string())
  29. # Should be mailServer.quit(), but that crashes...
  30. mailServer.close()
  31.  
  32. mail('paulthom12345@gmail.com',
  33. 'subject',
  34. 'Hello from python')
Cheers!
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 1,370
Reputation: evstevemd has a spectacular aura about evstevemd has a spectacular aura about evstevemd has a spectacular aura about 
Solved Threads: 127
evstevemd's Avatar
evstevemd evstevemd is offline Offline
Nearly a Posting Virtuoso

Re: Import error with py2exe

 
0
  #2
Dec 5th, 2008
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 902
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 145
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Import error with py2exe

 
0
  #3
Dec 5th, 2008
Yeah, the problem seems to be that the email module is not being packed with the .exe file and i couldn't find a way to get it to be. Does anyone know how i can package all of the stuff i import?
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Join Date: Apr 2008
Posts: 670
Reputation: Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough Freaky_Chris is a jewel in the rough 
Solved Threads: 113
Freaky_Chris's Avatar
Freaky_Chris Freaky_Chris is offline Offline
Practically a Master Poster

Re: Import error with py2exe

 
0
  #4
Dec 6th, 2008
This is a common problem, it seems you have to manually include the mail module, this link maybe of help to you
http://stackoverflow.com/questions/1...am-with-py2exe

Also another suggestion rather than py2exe use bbfreeze
http://pypi.python.org/pypi/bbfreeze/0.95.4

Chris
Knowledge is power -- But experience is everything
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 902
Reputation: Paul Thompson has a spectacular aura about Paul Thompson has a spectacular aura about 
Solved Threads: 145
Sponsor
Paul Thompson's Avatar
Paul Thompson Paul Thompson is offline Offline
previously paulthom12345

Re: Import error with py2exe

 
0
  #5
Dec 6th, 2008
Chris the first one worked a charm. Thanks!
Make it idiot proof and someone will make a better idiot.
Check out my Site | and join us on IRC | Python Specific IRC
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC