python 中导入错误
出现以下错误
Traceback (most recent call last):
File "myemail.py", line 1, in <module>
import smtplib
File "/usr/lib/python2.6/smtplib.py", line 46, in <module>
import email.utils
File "/home/nikhil/Desktop/bujji/email.py", line 2, in <module>
ImportError: No module named MIMEMultipart
当我运行 代码示例时,
我试图用谷歌搜索错误,但没有任何效果。
I get the following error
Traceback (most recent call last):
File "myemail.py", line 1, in <module>
import smtplib
File "/usr/lib/python2.6/smtplib.py", line 46, in <module>
import email.utils
File "/home/nikhil/Desktop/bujji/email.py", line 2, in <module>
ImportError: No module named MIMEMultipart
when i run the code example
I tried to google out the error but nothing worked.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您已经通过命名脚本
email.py
来访问 stdlib 中的email
包。重命名它。You've stomped on the
email
package in the stdlib by naming a scriptemail.py
. Rename it.没有足够的声誉来评论 Ignacio Vazquez-Abrams 的答案,但请确保不仅删除 email.py,还添加 email.py~ 和 email.pyc 等内容
Don't have enough reputation to comment on Ignacio Vazquez-Abrams's answer but make sure that not only do you remove email.py put also things like email.py~ and email.pyc
包名称已更改。我相信新名称是
email.mime.multipart
。只需调整您的导入以导入
email.mime.multipart
而不是email.MIMEMultipart
。另外,请注意,
email.MIMEBase
现在是email.mime.base
,email.MIMEText
现在是email.mime.text
。The package names have changed. I believe that the new name is
email.mime.multipart
.Just adapt your imports to import
email.mime.multipart
instead ofemail.MIMEMultipart
.Also, be aware that
email.MIMEBase
is nowemail.mime.base
andemail.MIMEText
is nowemail.mime.text
.