I just insta开发者_运维知识库lled libgmail on CentOS 5, python 2.6 with easy_install. There was a problem, until i installed mechanize manually. After that easy_install said OK and i wrote 1st test program from the sample i googled:
import libgmail
ga = libgmail.GmailAccount("someaccount@gmail.com", "mypassword")
ga.login()
folder = ga.getMessagesByFolder('inbox')
for thread in folder:
print thread.id, len(thread), thread.subject
for msg in thread:
print " ", msg.id, msg.number, msg.subject
print msg.source
I get the following error message:
Traceback (most recent call last):
File "gm.py", line 4, in <module>
ga.login()
File "build/bdist.linux-i686/egg/libgmail.py", line 305, in login
File "build/bdist.linux-i686/egg/libgmail.py", line 340, in _retrievePage
File "build/bdist.linux-i686/egg/mechanize/_request.py", line 31, in __init__
File "build/bdist.linux-i686/egg/mechanize/_rfc3986.py", line 62, in is_clean_uri
TypeError: expected string or buffer
It seems, i get a problem not with my python code, but with libgmail installation. Any clues, anyone?
libgmail is deprecated and has stopped developing, since gmail started offering imap access.
Use imaplib
or similar (twisted.mail
comes to mind, example code here).
精彩评论