IO error in Python
<p>I am trying to run this code:</p>

<pre><code>    import urllib
    htmlfile = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&amp;ei=7VzrV6WWG8KC0ATxor_IDw")
    htmltext = htmlfile.read()
    print htmltext
</code></pre>

<p>But the following error is shown, when I run the code:</p>

<pre><code>    Traceback (most recent call last):
    File "C:\Python27\newscrap.py", line 2, in &lt;module&gt;
    htmlfile = urllib.urlopen("https://www.google.co.in/?gfe_rd=cr&amp;ei=7VzrV6WWG8KC0ATxor_IDw")
    File "C:\Python27\lib\urllib.py", line 87, in urlopen
    return opener.open(url)
    File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
    File "C:\Python27\lib\urllib.py", line 443, in open_https
h.endheaders(data)
    File "C:\Python27\lib\httplib.py", line 997, in endheaders
self._send_output(message_body)
    File "C:\Python27\lib\httplib.py", line 850, in _send_output
self.send(msg)
    File "C:\Python27\lib\httplib.py", line 812, in send
self.connect()
    File "C:\Python27\lib\httplib.py", line 1208, in connect
HTTPConnection.connect(self)
    File "C:\Python27\lib\httplib.py", line 793, in connect
self.timeout, self.source_address)
    File "C:\Python27\lib\socket.py", line 553, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
     IOError: [Errno socket error] [Errno 11004] getaddrinfo failed
</code></pre>

<p>Can anyone tell why this error occurs?</p>

<p>It's a connection problem (your code works on my computer). Check your firewall / proxy settings / dns server / other connection settings.</p>

python