我刚刚在CentOS 5上安装了libgmail,使用easy_install安装了python 2.6。有一个问题,直到我手动安装机械化。之后,easy_install说OK,我从样本中写了第一个测试程序,我用Google搜索:
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
我收到以下错误消息:
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
看来,我遇到的问题不是我的python代码,而是安装了libgmail。任何线索,任何人?
答案 0 :(得分:2)
libgmail已被弃用,并且已停止开发,因为gmail开始提供imap访问权限。
使用imaplib
或类似内容(twisted.mail
会想到,示例代码here)。