1

I am trying to get the data from Elasticsearch (ver. 1.7), and post it into Elasticsearch (ver. 5.2) using Elasticsearch-py with 1 Python script. But the recommended way within official docummentation (https://elasticsearch-py.readthedocs.io/en/master/) is:

Elasticsearch 5.x for elasticsearch>=5.0.0,<6.0.0

Elasticsearch 1.x for elasticsearch>=1.0.0,<2.0.0

The question is how may I install 2 different versions of elasticsearch-py and use those within 1 Python script (I'm using virtualenv)?


I've already checked all the questions like: Installing multiple versions of a package with pip , here are some ideas suggested, but is there some better way to achieve this?

Nikolay Vasiliev
  • 5,656
  • 22
  • 31
Olia
  • 815
  • 4
  • 16

1 Answers1

1

how about that

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

and then you should be able to import it like this

from old import elasticsearch
from new import elasticsearch
hello world
  • 596
  • 2
  • 12
  • Thank you for the answer, but this gives ImportError: No module named – Olia May 04 '17 at 10:34
  • (venv) magniff@magniffy700:~/workspace/venv $ pip install -t es_new elasticsearch==5.0.0 and then just python -c 'from es_new import elasticsearch as es_new'. Works fine. – hello world May 04 '17 at 11:05