Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python pip raising NewConnectionError while installing libraries

Tags:

I've Python 3 running in a linux server. I need to install some libraries (obviously) so I'm trying :

pip3 install numpy

Which, is resulting in the following error:

Collecting numpy
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7542572828>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/numpy/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7542572eb8>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/numpy/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7542572be0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/numpy/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7542572d30>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/numpy/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7542572860>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /simple/numpy/
  Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy

Questions:

  1. What could be the problem? Why is this error being raised?
  2. How can this be avoided in the future?

Feel free to ask for more details.

UPDATE: I tried ping google.com and got the error:

ping: google.com: Name or service not known

But when I tried ping 8.8.8.8, I got:

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=118 time=10.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=118 time=10.6 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=118 time=10.6 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=5 ttl=118 time=10.6 ms
64 bytes from 8.8.8.8: icmp_seq=6 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=7 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=8 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=9 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=10 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=11 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=12 ttl=118 time=10.8 ms
64 bytes from 8.8.8.8: icmp_seq=13 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=14 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=15 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=16 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=17 ttl=118 time=10.6 ms
64 bytes from 8.8.8.8: icmp_seq=18 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=19 ttl=118 time=10.6 ms
64 bytes from 8.8.8.8: icmp_seq=20 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=21 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=22 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=23 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=24 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=25 ttl=118 time=10.7 ms
64 bytes from 8.8.8.8: icmp_seq=26 ttl=118 time=10.7 ms
^C
--- 8.8.8.8 ping statistics ---
26 packets transmitted, 26 received, 0% packet loss, time 25046ms
rtt min/avg/max/mdev = 10.655/10.731/10.827/0.073 ms

A problem with DNS maybe? What should I do?

like image 852
Mooncrater Avatar asked Oct 15 '18 11:10

Mooncrater


2 Answers

All I had to do was add nameserver 8.8.8.8 to the /etc/resolv.conf file. 8.8.8.8 is Google's public free DNS server's IP. So, since a system must know the IP address of a domain name, we have to give it a way to do just that. A public DNS server provides this binding of a domain name to the IP address.

like image 135
Mooncrater Avatar answered Sep 19 '22 13:09

Mooncrater


For Windows 10 User, Go to Settings -> Network and Internet -> Proxy

Disable Automatically detect settings

enter image description here

like image 42
Ankit Patel Avatar answered Sep 18 '22 13:09

Ankit Patel