ValueError:URL 必须包含“方案”、“主机”和“端口”组件

Ans*_*pta 8 pycharm elasticsearch

尝试在项目中使用弹性搜索。

from elasticsearch import Elasticsearch
es = Elasticsearch(
    "https://example.com",
    http_auth=("abc", "bcd"),
)
Run Code Online (Sandbox Code Playgroud)

但出现错误:

ValueError: URL must include a 'scheme', 'host', and 'port' component (ie 'https://localhost:9200')
Run Code Online (Sandbox Code Playgroud)

我在 Pycharm CE 上运行它并创建了 Python 3.9 的虚拟环境。我应该使用不同版本的 Python 来完成这项工作吗?而且,我已经尝试过了pip install acryl-datahub[datahub-rest,elasticsearch]==0.8.27.1,但没有成功。

小智 7

我面临着同样的错误。安装ES 7.17版本解决了这个问题。我还得到了一个不可用的信息pip install acryl-datahub[datahub-rest,elasticsearch]==0.8.27.1。尝试使用下一个可用版本 (0.8.28.0),并意识到它正在降级elasticsearch到 7.17。

所以尝试一下pip install elasticsearch==7.17