# Hail import into python error

**URL:** <https://discuss.hail.is/t/hail-import-into-python-error/163>\
**Category:** Help \[0.1\]\
**Created:** [March 16, 2017, 6:15pm UTC](https://discuss.hail.is/t/hail-import-into-python-error/163 "2017-03-16T18:15:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffrye](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@jeffrye](https://discuss.hail.is/u/jeffrye)\
**Post date:** [March 16, 2017, 6:15pm UTC](https://discuss.hail.is/t/hail-import-into-python-error/163/1 "2017-03-16T18:15:43Z")

</div>

I’m fumbling along with installing hail locally. When importing into python, I get this error (ImportError: No module named py4j.protocol). Any help is appreciated.  
Jeff

VIPBGB1L01130AB:hail jalexander4$ ipython  
Python 2.7.13 |Anaconda 4.3.1 (x86\_64)| (default, Dec 20 2016, 23:05:08)  
Type “copyright”, “credits” or “license” for more information.

IPython 5.1.0 – An enhanced Interactive Python.  
? -\> Introduction and overview of IPython’s features.  
%quickref -\> Quick reference.  
help -\> Python’s own help system.  
object? -\> Details about ‘object’, use ‘object??’ for extra details.

## In [1]: import hail

ImportError Traceback (most recent call last)  
 in ()  
----\> 1 import hail

/Users/jalexander4/hail/python/hail/ **init**.py in ()  
----\> 1 from hail.context import HailContext  
2 from hail.dataset import VariantDataset  
3 from hail.keytable import KeyTable  
4 from hail.utils import TextTableConfig  
5 from hail.type import Type

/Users/jalexander4/hail/python/hail/context.py in ()  
1 from **future** import print\_function # Python 2 and 3 print compatibility  
2  
----\> 3 from pyspark.sql import SQLContext  
4  
5 from hail.dataset import VariantDataset

/Users/jalexander4/spark-2.1.0-bin-hadoop2.7/python/pyspark/ **init**.py in ()  
42  
43 from pyspark.conf import SparkConf  
—\> 44 from pyspark.context import SparkContext  
45 from pyspark.rdd import RDD  
46 from pyspark.files import SparkFiles

/Users/jalexander4/spark-2.1.0-bin-hadoop2.7/python/pyspark/context.py in ()  
27 from tempfile import NamedTemporaryFile  
28  
—\> 29 from py4j.protocol import Py4JError  
30  
31 from pyspark import accumulators

ImportError: No module named py4j.protocol

In [2]:

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [March 16, 2017, 6:29pm UTC](https://discuss.hail.is/t/hail-import-into-python-error/163/2 "2017-03-16T18:29:02Z")

</div>

Make sure that you’ve added the py4j library to your python path, as here: [https://hail.is/hail/getting\_started.html](https://hail.is/hail/getting_started.html)

If you’re using a slightly different version of spark, it’s possible that the py4j version is different, too – make sure you’ve actually got the 0.10.3 version at `$SPARK_HOME/python/lib/py4j-0.10.3-src.zip`, or modify it to match.

---

<div class="post-metadata">

**Author:** ![jeffrye](https://avatars.discourse-cdn.com/v4/letter/j/3d9bf3/32.png) [@jeffrye](https://discuss.hail.is/u/jeffrye)\
**Post date:** [March 16, 2017, 6:42pm UTC](https://discuss.hail.is/t/hail-import-into-python-error/163/3 "2017-03-16T18:42:14Z")

</div>

Thanks, it’s working now. I had Spark 10.4.
