0

I have to use python-elasticsearch library on a machine where I could only execute programs. I am trying to use elasticsearch module by appending sys.path as mentioned below. I am facing below issue. It looks like the problem related to what is mentioned here https://github.com/elastic/elasticsearch-py/issues/253 . But how do I resolve this when I dont have sudo access or any sort of upgrade access.

**Note :**I don't have sudo access on this machine so I cannot have venv, pip etc.

    import sys
    sys.path.append('/tmp/elasticpy/elasticsearch-2.3.0')
    from elasticsearch import Elasticsearch
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/__init__.py", line 17, in <module>
        from .client import Elasticsearch
      File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/client/__init__.py", line 5, in <module>
        from ..transport import Transport
      File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/transport.py", line 4, in <module>
        from .connection import Urllib3HttpConnection
      File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/connection/__init__.py", line 3, in <module>
        from .http_urllib3 import Urllib3HttpConnection
      File "/tmp/elasticpy/elasticsearch-2.3.0/elasticsearch/connection/http_urllib3.py", line 2, in <module>
        import urllib3
    ImportError: No module named urllib3
techrawther
  • 153
  • 3
  • 14

1 Answers1

0

@nehal Thanks for your suggestion I was able to get it fixed. Please find the series of steps I used to install

  1. Used easy_install to install package pip
  2. Appended PYTHONPATH
  3. used pip to install virtualenv
  4. Activated new virtualenv
  5. Installed elasticsearch using pip

    export PYTHONPATH="${PYTHONPATH}:/tmp/pytest/"
    easy_install  --install-dir /tmp/pytest/  pip       
    pip install virtualenv --prefix /tmp/pytest/
    export PATH="${PATH}:/tmp/pytest:/tmp/pytest/bin"
    export PYTHONPATH="${PYTHONPATH}:/tmp/pytest/lib/python2.7/site-packages"
    cd /tmp/
    virtualenv venv
    source venv/bin/activate
    pip install elasticsearch
    
techrawther
  • 153
  • 3
  • 14