Jesse Evans
Jesse Evans

Reputation: 21

Having problems importing smtplib with Python

When I have a simple python code of:

import smtplib

I am getting the error:

Traceback (most recent call last):
  File "C:\Users\David\Desktop\email.py", line 25, in <module>
    from smtplib import SMTP_SSL as SMTP       # this invokes the secure SMTP pr
otocol (port 465, uses SSL)
  File "C:\Python27\lib\smtplib.py", line 1
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtm
l11/DTD/xhtml11.dtd">
    ^
SyntaxError: invalid syntax

I'm not sure what I'm doing wrong.

Upvotes: 2

Views: 470

Answers (1)

mata
mata

Reputation: 69012

The only explanation would be that your smtplib.py somehow got replaced with a html file. Try to open C:\Python27\lib\smtplib.py in a text editor and check.

I can't tell you how this could have happened, but probably it would be best to reinstall python in this case.

Upvotes: 2

Related Questions