【问题标题】:Different version of Elasticsearch-py lib within Python scriptPython 脚本中不同版本的 Elasticsearch-py lib
【发布时间】:2017-05-04 09:36:21
【问题描述】:

我正在尝试从 Elasticsearch(1.7 版)获取数据,并使用带有 1 个 Python 脚本的 Elasticsearch-py 将其发布到 Elasticsearch(5.2 版)。 但官方文档 (https://elasticsearch-py.readthedocs.io/en/master/) 中推荐的方式是:

Elasticsearch 5.x for elasticsearch>=5.0.0,

Elasticsearch 1.x for elasticsearch>=1.0.0,

问题是如何安装 2 个不同版本的 elasticsearch-py 并在 1 个 Python 脚本中使用它们(我正在使用 virtualenv)?


我已经检查了所有问题,例如: Installing multiple versions of a package with pip ,这里有一些建议,但是有没有更好的方法来实现这一点?

【问题讨论】:

    标签: python python-2.7 elasticsearch-py


    【解决方案1】:

    怎么样

    pip install -t old oldelasticsearch
    pip install -t new newelasticsearch
    

    然后你应该可以像这样导入它

    from old import elasticsearch
    from new import elasticsearch
    

    【讨论】:

    • 感谢您的回答,但这给出了 ImportError: No module named
    • (venv) magniff@magniffy700:~/workspace/venv $ pip install -t es_new elasticsearch==5.0.0 然后只是 python -c 'from es_new import elasticsearch as es_new'。工作正常。
    猜你喜欢
    • 2020-04-20
    • 2010-10-17
    • 1970-01-01
    • 1970-01-01
    • 2021-08-13
    • 2023-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-17
    相关资源
    最近更新 更多