Я использую библиотеку Geopy
для преобразования списка английских названий мест в широту и долготу.Однако в середине выполнения программа вызвала ошибку: OSError: [Errno 101] Network is unreachable
.Мне было интересно, если это связано с моим кодом или это просто ошибка сети?
Мой код:
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.')
Полное исключение выглядит следующим образом:
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