# Python Elasticsearch urllib3 exception

**URL:** <https://discuss.elastic.co/t/python-elasticsearch-urllib3-exception/59730>\
**Category:** Elasticsearch\
**Created:** [September 3, 2016, 5:01pm UTC](https://discuss.elastic.co/t/python-elasticsearch-urllib3-exception/59730 "2016-09-03T17:01:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![techrawther](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@techrawther](https://discuss.elastic.co/u/techrawther)\
**Post date:** [September 3, 2016, 5:01pm UTC](https://discuss.elastic.co/t/python-elasticsearch-urllib3-exception/59730/1 "2016-09-03T17:01:48Z")

</div>

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](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.

```
	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
```

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [September 3, 2016, 5:57pm UTC](https://discuss.elastic.co/t/python-elasticsearch-urllib3-exception/59730/2 "2016-09-03T17:57:52Z")

</div>

Don't modify sys.path like that. Use virtualenv to create a sandboxed Python environment where you can install any packages (including elasticsearch-py). Something like this should work:

```nohighlight
virtualenv .python
source .python/bin/activate
pip install elasticsearch

```

(If the system doesn't have virtualenv you obviously have to install it first, but that's totally doable even without root access.)

---

<div class="post-metadata">

**Author:** ![techrawther](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@techrawther](https://discuss.elastic.co/u/techrawther)\
**Post date:** [September 8, 2016, 5:16am UTC](https://discuss.elastic.co/t/python-elasticsearch-urllib3-exception/59730/3 "2016-09-08T05:16:00Z")

</div>

Thank @magnusbaeck . PIP was not installed in this machine hence I could not install vevn and elasticsearch directly.

I was able to resolve this be using easy\_install to install pip to a directory where I had permission and then later vevn and then elasticsearch. Please find the steps I followed to resolve it.

```
	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
```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:21pm UTC](https://discuss.elastic.co/t/python-elasticsearch-urllib3-exception/59730/4 "2017-07-05T22:21:54Z")

</div>


