简体   繁体   English

Python:使用py2exe编译时出错

[英]Python: error when is compiled with py2exe

I have a script in python that send an email 我在python中有一个脚本可以发送电子邮件

import email
import email.mime.application
...
msg = email.mime.Multipart.MIMEMultipart()
    msg['Subject'] = 'test'
    msg['From'] = 'test@gmail.com'
    msg['To'] = 'test@gmail.com'
body = email.mime.Text.MIMEText("""test""")

....

In python the script is running well, but after I compile it with py2exe I get this error 在python中,脚本运行良好,但是用py2exe编译后,出现此错误

Traceback (most recent call last):
  File "mail.py", line 13, in <module>
  File "email\__init__.pyc", line 79, in __getattr__
ImportError: No module named multipart

In the py2exe compilation log I see this message 在py2exe编译日志中,我看到此消息

...
The following modules appear to be missing
['_scproxy', 'email.MIMEBase', 'email.MIMEMultipart', 'email.MIMEText']
....

Any idea how to fix this ? 任何想法如何解决这个问题? Thanks 谢谢

If in python the script runs well, it seems that py2exe is not including all the needed modules. 如果在python中脚本运行良好,则py2exe似乎未包含所有必需的模块。

Take a look at this question Python - Py2exe can't build .exe using the 'email' module 看看这个问题Python-Py2exe无法使用'email'模块构建.exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM