Import hail error: TypeError: an integer is required (got type bytes)

Hello,
I followed the instructions on this website to install Hail: https://hail.is/docs/0.2/install/macosx.html

In ipython3, I try “import hail” and I get the error message on the bottom.

I tried pip installing table and pyspark, but the same error occurred. I am running on MacOS 10.12.6.

Thanks for your help!

In [1]: import hail
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-e24d842d2b9a> in <module>
----> 1 import hail

~/miniconda3/lib/python3.8/site-packages/hail/__init__.py in <module>
     29 # F401 '.expr.*' imported but unused
     30 # E402 module level import not at top of file
---> 31 from .table import Table, GroupedTable, asc, desc  # noqa: E402
     32 from .matrixtable import MatrixTable, GroupedMatrixTable  # noqa: E402
     33 from .expr import *  # noqa: F401,F403,E402

~/miniconda3/lib/python3.8/site-packages/hail/table.py in <module>
      2 import itertools
      3 import pandas
----> 4 import pyspark
      5 from typing import Optional, Dict, Callable
      6

~/miniconda3/lib/python3.8/site-packages/pyspark/__init__.py in <module>
     49
     50 from pyspark.conf import SparkConf
---> 51 from pyspark.context import SparkContext
     52 from pyspark.rdd import RDD, RDDBarrier
     53 from pyspark.files import SparkFiles

~/miniconda3/lib/python3.8/site-packages/pyspark/context.py in <module>
     29 from py4j.protocol import Py4JError
     30
---> 31 from pyspark import accumulators
     32 from pyspark.accumulators import Accumulator
     33 from pyspark.broadcast import Broadcast, BroadcastPickleRegistry

~/miniconda3/lib/python3.8/site-packages/pyspark/accumulators.py in <module>
     95     import socketserver as SocketServer
     96 import threading
---> 97 from pyspark.serializers import read_int, PickleSerializer
     98
     99

~/miniconda3/lib/python3.8/site-packages/pyspark/serializers.py in <module>
     69     xrange = range
     70
---> 71 from pyspark import cloudpickle
     72 from pyspark.util import _exception_message
     73

~/miniconda3/lib/python3.8/site-packages/pyspark/cloudpickle.py in <module>
    143
    144
--> 145 _cell_set_template_code = _make_cell_set_template_code()
    146
    147

~/miniconda3/lib/python3.8/site-packages/pyspark/cloudpickle.py in _make_cell_set_template_code()
    124         )
    125     else:
--> 126         return types.CodeType(
    127             co.co_argcount,
    128             co.co_kwonlyargcount,

TypeError: an integer is required (got type bytes)

Hail can only be run on Python versions >= 3.6 and < 3.8, due to the dependency on Pyspark which can’t run on Python 3.8. If you try with a Python 3.7 installation things should work.

Thank you!

Note that this is no longer accurate. Newer versions of hail now support all Python versions >= 3.6.

1 Like