文件名不能与标准库的名称一样

今天写了个发邮件的脚本,名字叫email.py
运行的时候报
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1521, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./email.py", line 4, in <module>
    import smtplib
  File "/usr/local/python3/lib/python3.3/smtplib.py", line 47, in <module>
    import email.utils
  File "/root/study/python/email.py", line 5, in <module>
    from email.mime.text  import MIMEText
ImportError: No module named 'email.mime'; email is not a package

竟然还出现了一个目录 __pycache__,

百思不得其解,还以为是升级python3的时候出问题了,通过网上查询,
smtplib.py中import email.utils这一句,又说email.py中无mime.text。可以推断是文件名与标准库名冲突
解决:
将email.py改为别的名字,解决

你可能感兴趣的:(文件)