Vote count:
0
I'm start using Pydev in Eclipse.
My phtyon version is 3.4.3
This is my Code that I want to run
import smtplib
from email.mime.text import MIMEText
import codecs
fp = codecs.open("/Users/Chois/Desktop/textfile", 'rb', 'utf-8')
msg = MIMEText(fp.read())
fp.close()
me = "abcd@gmail.com"
you = "efgh@naver.com"
msg['Subject'] = "hi.."
msg['From'] = me
msg['To'] = you
s = smtplib.SMTP_SSL('smtp.gmail.com',465)
s.login(me, "password")
s.sendmail(me, you, msg.as_string())
s.quit()
It runs well in Terminal by "python test.py".
However, when I tried to run it in Pydev, There are some errors something like belows
Traceback (most recent call last):
File "/Users/Chois/Downloads/eclipse/plugins/org.python.pydev_3.9.2.201502050007/pysrc/pydevd.py", line 2235, in <module>
globals = debugger.run(setup['file'], None, None)
File "/Users/Chois/Downloads/eclipse/plugins/org.python.pydev_3.9.2.201502050007/pysrc/pydevd.py", line 1661, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/Users/Chois/Documents/workspace/Test/src/test.py", line 9, in <module>
msg = MIMEText(fp.read())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/mime/text.py", line 30, in __init__
self.set_payload(_text, _charset)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py", line 226, in set_payload
self.set_charset(charset)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/email/message.py", line 262, in set_charset
self._payload = self._payload.encode(charset.output_charset)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-4: ordinal not in range(128)
I don't know why this happen.
And below is the setting that I used when making python project file in Pydev
I would be really thankful if you gonna give advices or somethings. Thanks.
asked 51 secs ago
Pydev can not run the .py file which run well in Terminal
Aucun commentaire:
Enregistrer un commentaire