This is a test version of Biostars. For the public version, visit https://www.biostars.org.
TypeError: an integer is required (got type bytes)

I am trying to import hail and gnomad libraries but its showing me the error. Here is the code

from gnomad.resources.grch37 import gnomad
gnomad_v2_exomes = gnomad.public_release("exomes")
exomes_ht = gnomad_v2_exomes.ht()
exomes_ht.describe()

This is the error.

Traceback (most recent call last):
 File "C:\....\PycharmProjects\Databases\exac.py", line 1, in <module>
from gnomad.resources.grch37 import gnomad
File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\gnomad\resources\__init__.py", line 1, in <module>
from .resource_utils import *
File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\gnomad\resources\resource_utils.py", line 3, in <module>
import hail as hl
File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\hail\__init__.py", line 34, in <module>
 from .table import Table, GroupedTable, asc, desc  # noqa: E402
 File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\hail\table.py", line 4, in <module>
import pyspark
 File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\__init__.py", line 51, in <module>
from pyspark.context import SparkContext
from pyspark import accumulators
File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\accumulators.py", line 97, in <module>
from pyspark.serializers import read_int, PickleSerializer
File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\serializers.py", line 71, in <module>
from pyspark import cloudpickle
 File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\cloudpickle.py", line 145, in <module>
 _cell_set_template_code = _make_cell_set_template_code()
File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\cloudpickle.py", line 126, in 
_make_cell_set_template_code
return types.CodeType(
TypeError: an integer is required (got type bytes)
Process finished with exit code 1

How to fix it? I have tried to resolve it with different versions of pyspark but this error is not getting resolved anyway. I am using python version 3.9 on pycharm.

python exac gnoamd hail

You should add code, textual descritions alone are hard to debug.

Here is the code

from gnomad.resources.grch37 import gnomad
gnomad_v2_exomes = gnomad.public_release("exomes")
exomes_ht = gnomad_v2_exomes.ht()
exomes_ht.describe()

And here is the error

Traceback (most recent call last):
  File "C:\....\PycharmProjects\Databases\exac.py", line 1, in <module>
    from gnomad.resources.grch37 import gnomad
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\gnomad\resources\__init__.py", line 1, in <module>
    from .resource_utils import *
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\gnomad\resources\resource_utils.py", line 3, in <module>
    import hail as hl
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\hail\__init__.py", line 34, in <module>
    from .table import Table, GroupedTable, asc, desc  # noqa: E402
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\hail\table.py", line 4, in <module>
    import pyspark
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\__init__.py", line 51, in <module>
    from pyspark.context import SparkContext
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\context.py", line 31, in <module>
    from pyspark import accumulators
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\accumulators.py", line 97, in <module>
    from pyspark.serializers import read_int, PickleSerializer
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\serializers.py", line 71, in <module>
    from pyspark import cloudpickle
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\cloudpickle.py", line 145, in <module>
    _cell_set_template_code = _make_cell_set_template_code()
  File "C:\....\PycharmProjects\Databases\venv\lib\site-packages\pyspark\cloudpickle.py", line 126, in _make_cell_set_template_code
    return types.CodeType(
TypeError: an integer is required (got type bytes)

A couple of points to note:

  1. Edit your post and add the code in there so people don't have to read through the comments to get a full context.
  2. Please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. If your code has long lines with a single command, break those lines into multiple lines with proper escape sequences so they're easier to read and still run when copy-pasted. I've done it for you this time.
    code_formatting

0 answers

No answers yet.

Log in to answer this question.