I'm using Geopy
library to convert a list of English name locations to latitude and longitude. However, halfway through the execution, the program raised an error: OSError: [Errno 101] Network is unreachable
. I was wondering if there's related to my code or it's simply the network error?
My code:
from geopy.geocoders import Nominatim
import pandas as pd
df = pd.read_csv('/*****.csv')
for cell in df['Offices']:
cell = pinyin.get(cell, format="strip", delimiter='')
place = str(cell)
geolocator = Nominatim(timeout=3)
location = geolocator.geocode(place)
print(location)
if location:
print((location.latitude, location.longitude))
print('Converting finished.')
The full exception as follows:
Traceback (most recent call last):
File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
encode_chunked=req.has_header('Transfer-encoding'))
File "/usr/lib/python3.6/http/client.py", line 1239, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
self.send(msg)
File "/usr/lib/python3.6/http/client.py", line 964, in send
self.connect()
File "/usr/lib/python3.6/http/client.py", line 1392, in connect
super().connect()
File "/usr/lib/python3.6/http/client.py", line 936, in connect
(self.host,self.port), self.timeout, self.source_address)
File "/usr/lib/python3.6/socket.py", line 724, in create_connection
raise err
File "/usr/lib/python3.6/socket.py", line 713, in create_connection
sock.connect(sa)
OSError: [Errno 101] Network is unreachable