Connecting to Gmail from Python -
i've been trying connect gmail account using python. imap
enabled.
import imaplib imap_server = imaplib.imap4_ssl("imap.gmail.com",993) # tried imap_server = imaplib.imap4_ssl("imap.gmail.com"), doesnt work.
traceback :
traceback (most recent call last): file "<pyshell#2>", line 1, in <module> imap_server = imaplib.imap4_ssl("imap.gmail.com",993) file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/imaplib.py", line 1202, in __init__ imap4.__init__(self, host, port) file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/imaplib.py", line 172, in __init__ self.open(host, port) file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/imaplib.py", line 1217, in open imap4.open(self, host, port) file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/imaplib.py", line 248, in open self.sock = self._create_socket() file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/imaplib.py", line 1205, in _create_socket sock = imap4._create_socket(self) file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/imaplib.py", line 238, in _create_socket return socket.create_connection((self.host, self.port)) file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/socket.py", line 435, in create_connection raise err file "/library/frameworks/python.framework/versions/3.3/lib/python3.3/socket.py", line 426, in create_connection sock.connect(sa) oserror: [errno 65] no route host
what oserror: [errno 65] no route host
means say: can't machine machine.
you can test outside of python opening terminal/dos prompt , typing this:
ping imap.gmail.com
it's possible name lookup error, , you're somehow getting bad address imap.gmail.com
. so, sure, check ip address too:
ping 74.125.129.108 ping 74.125.129.109
if ping
works, can check whether router reason blocking tcp access host, e.g., with:
telnet imap.gmail.com
if it's working, should either hang long time, or give connection-refused error; if gives no-route-to-host error, it's same problem you're seeing.
it's possible router blocking port 993. can test too:
telnet imap.gmail.com 993
if doesn't come "connected gmail-imap.l.google.com", same problem here too.
at rate, once you've verified system or network configuration problem, not programming problem, go ask system on appropriate site.
Comments
Post a Comment