Getting error when running requests.get
Hello All,
I tried to run below code:
- import requests
- r = requests.get("http://google.com")
- print("status: ", r.status_code)
- print(r.url)
but, after a long wait, i get this error:
Traceback (most recent call last):
File "C:\Python3\lib\site-packages\urllib3\connection.py", line 141, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "C:\Python3\lib\site-packages\urllib3\util\connection.py", line 83, in create_connection
raise err
File "C:\Python3\lib\site-packages\urllib3\util\connection.py", line 73, in create_connection
sock.connect(sa)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python3\lib\site-packages\urllib3\connectionpool.py", line 601, in urlopen
chunked=chunked)
File "C:\Python3\lib\site-packages\urllib3\connectionpool.py", line 346, in _make_request
self._validate_conn(conn)
File "C:\Python3\lib\site-packages\urllib3\connectionpool.py", line 850, in _validate_conn
conn.connect()
File "C:\Python3\lib\site-packages\urllib3\connection.py", line 284, in connect
conn = self._new_conn()
File "C:\Python3\lib\site-packages\urllib3\connection.py", line 150, in _new_conn
self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x030403F0>: Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
During handling of the above exception, another exception occurred:
Looks like Pycharm is not able to connect to the Internet.
I am getting similar message when i try to install any package from within Pycharm:
Collecting virtualenv
Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection broken by 'ConnectTimeoutError(<pip._vendor.requests.packages.urllib3.connection.VerifiedHTTPSConnec
tion object at 0x033FB430>, 'Connection to pypi.python.org timed out. (connect timeout=15)')': /simple/virtualenv/
Can anyone please help me urgently.
Please sign in to leave a comment.
Hello,
Does the same script work from command line? Do you have any proxy configured in "Settings | Appearance & Behavior | System Settings | HTTP Proxy"?
Hello,
It is not running from command line also.
I don't have any proxy configured in above specified path.
Thanks
Do you use any antivirus software or firewall/proxy. Looks like something is blocking network activity so your scripts don't run.