Как подключиться с помощью google-листов на AWS Server-ubuntu 14.04 LTS с помощью pygsheets?
Я пытаюсь связаться с одним из моих Google-листов, чтобы получить данные. Я использую Python/pygsheets для подключения. Проблема в том, что его рабочий файл на локальной машине. но выведите на сервер следующую ошибку (AWS-ubuntu 14.04 LTS):
address_info = socket.getaddrinfo(host, port, 0, socket.SOCK_STREAM) File "/usr/lib/python3.4/socket.py", line 533, in getaddrinfo for res in _socket.getaddrinfo(host, port, family, type, proto, flags): socket.gaierror: [Errno -2] Name or service not known During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.4/dist-packages/pygsheets/client.py", line 595, in authorize rclient = Client(oauth=credentials, **client_kwargs) File "/usr/local/lib/python3.4/dist-packages/pygsheets/client.py", line 84, in __init__ self._spreadsheeets = self._fetch_sheets() File "/usr/local/lib/python3.4/dist-packages/pygsheets/client.py", line 99, in _fetch_sheets results = self._execute_request(None, request, False) File "/usr/local/lib/python3.4/dist-packages/pygsheets/client.py", line 455, in _execute_request response = request.execute() File "/usr/local/lib/python3.4/dist-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper return wrapped(*args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/googleapiclient/http.py", line 835, in execute method=str(self.method), body=self.body, headers=self.headers) File "/usr/local/lib/python3.4/dist-packages/googleapiclient/http.py", line 162, in _retry_request resp, content = http.request(uri, method, *args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/oauth2client/transport.py", line 159, in new_request credentials._refresh(orig_request_method) File "/usr/local/lib/python3.4/dist-packages/oauth2client/client.py", line 749, in _refresh self._do_refresh_request(http) File "/usr/local/lib/python3.4/dist-packages/oauth2client/client.py", line 780, in _do_refresh_request body=body, headers=headers) File "/usr/local/lib/python3.4/dist-packages/oauth2client/transport.py", line 282, in request connection_type=connection_type) File "/usr/local/lib/python3.4/dist-packages/httplib2/__init__.py", line 1514, in request (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey) File "/usr/local/lib/python3.4/dist-packages/httplib2/__init__.py", line 1264, in _request (response, content) = self._conn_request(conn, request_uri, method, body, headers) File "/usr/local/lib/python3.4/dist-packages/httplib2/__init__.py", line 1194, in _conn_request raise ServerNotFoundError("Unable to find the server at %s" % conn.host) httplib2.ServerNotFoundError: Unable to find the server at oauth2.googleapis.com </code>
Я использую следующий код на сервере:
from udf.connection import connect_gsheet from udf.udf import csv_writer ss = connect_gsheet('10zqeOH2CldPP42Qo42qRd1********-x2HokCRTVd9gN4') #Key Can't show to public sheet = ss.worksheet_by_title('urls') data = sheet.get_all_values(include_tailing_empty=False,include_tailing_empty_rows=False,majdim='ROWS') data = data[1:]
вот функция для подключения googlesheet:
def connect_gsheet (gsheet_key): путь = '/home/ секреты / учетные данные /' cjson = open(путь + "sheet_connect.json", 'r', кодировка = 'utf8') cjson = json.load(cjson) печать (cjson['client_email']) пытаться: gc = pygsheets.authorize(service_file= путь + "sheet_connect.json", no_cache=True, outh_nonlocal = True) ss = gc.open_by_key(gsheet_key) печать ("Таблица подключена!!! ") вернуть сс кроме исключения как ошибка: печать (ERR) проходитьЯ ожидаю, чтобы соединиться с Google-листом с ключом, а затем имя-листа. после этого мне нужно получить все значения в виде списка.
этот код работает нормально на локальной машине, но не на сервере.