0
我一直在嘗試使用python的elasticsearch庫連接到我的ElasticSearch主機。 因此,代碼看起來像:實例化Elasticsearch客戶端僅在使用python3時失敗
client = Elasticsearch(
["https://my-machine.io:9200"],
http_auth=("user", "password")
)
現在的問題是,當我使用Python 2.7解釋該指令是唯一的工作,而它無法使用python 3.6,生成以下錯誤:
File "/usr/local/lib/python3.6/site-packages/elasticsearch/client/__init__.py", line 171, in __init__
self.transport = transport_class(_normalize_hosts(hosts), **kwargs)
File "/usr/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 108, in __init__
self.set_connections(hosts)
File "/usr/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 163, in set_connections
connections = list(zip(connections, hosts))
File "/usr/local/lib/python3.6/site-packages/elasticsearch/transport.py", line 160, in _create_connection
return self.connection_class(**kwargs)
File "/usr/local/lib/python3.6/site-packages/elasticsearch/connection/http_urllib3.py", line 78, in __init__
raise ImproperlyConfigured("Root certificates are missing for certificate "
elasticsearch.exceptions.ImproperlyConfigured: Root certificates are missing for certificate validation. Either pass them in using the ca_certs parameter or install certifi to use it automatically.
Python版本:
$ python2 --version
Python 2.7.13
$ python3 --version
Python 3.6.1
在這兩種情況下,我使用了 「elasticsearch」 包,版本5.3.0
我一直沒能找到任何文件,建議根據所使用的python版本不同的行爲。 任何人都可以解釋爲什麼會發生這種情況?
在每種情況下您使用的是哪個版本的elasticsearch模塊? –
這可能有所幫助:https://access.redhat.com/articles/2039753 – Val
哪個版本的python 2可以使用? (因爲urllib的默認機制現在默認檢查證書)。在實例化你的客戶端時,你是否嘗試過使用參數'verify_certs = False'? – Adonis