2017-05-04 24 views
0

我試圖從Elasticsearch(版本1.7)獲取數據,並使用Elasticsearch-py與1個Python腳本將其發佈到Elasticsearch(版本5.2)中。 但是官方docummentation(https://elasticsearch-py.readthedocs.io/en/master/)內的推薦的方法是:Python腳本中的不同版本的Elsticsearch-py lib

爲elasticsearch> = 5.0.0 Elasticsearch 5.x的,對於elasticsearch> = 1.0 < 6.0.0

Elasticsearch 1.x的 .0,< 2.0.0

問題是我該如何安裝2個不同版本的elasticsearch-py,並在1個Python腳本中使用這些版本(我使用的是virtualenv)?


我已經檢查了所有喜歡的問題: Installing multiple versions of a package with pip ,這裏有一些想法建議,但有一些更好的方式來實現這一目標?

回答

0

怎麼樣

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

,然後你應該能夠將其導入這樣

from old import elasticsearch 
from new import elasticsearch 
+0

謝謝你的回答,但是這給導入錯誤:沒有名爲模塊 Olia

+0

(venv)magniff @ magniffy700:〜/ workspace/venv $ pip install -t es_new elasticsearch == 5.0.0然後只是python -c'from es_new import elasticsearch as es_new'。工作正常。 –

相關問題