import error in python

梦想与她 提交于 2019-12-22 03:36:08

问题


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.


回答1:


You've stomped on the email package in the stdlib by naming a script email.py. Rename it.




回答2:


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




回答3:


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 of email.MIMEMultipart.

Also, be aware that email.MIMEBase is now email.mime.base and email.MIMEText is now email.mime.text.



来源:https://stackoverflow.com/questions/6971085/import-error-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!