Skip to content

hail.init() fails with Python 3.11 #12759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dlcotter opened this issue Mar 7, 2023 · 1 comment · Fixed by #12766
Closed

hail.init() fails with Python 3.11 #12759

dlcotter opened this issue Mar 7, 2023 · 1 comment · Fixed by #12766

Comments

@dlcotter
Copy link

dlcotter commented Mar 7, 2023

What happened?

The following fails:

import hail as hl
hl.init()

with the error:

ImportError: cannot import name 'getargspec' from 'inspect' (/usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py)

when running Python 3.11.

The code importing getargspec is the Parsimonious library (see stacktrace below).

Version

0.2.109

Relevant log output

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 import hail as hl
      2 hl.init()

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/hail/__init__.py:33
     14 __doc__ = r"""
     15     __  __     <>__
     16    / /_/ /__  __/ /
   (...)
     27 To report a bug, please open an issue: https://github.com/hail-is/hail/issues
     28 """
     30 # F403 'from .expr import *' used; unable to detect undefined names
     31 # F401 '.expr.*' imported but unused
     32 # E402 module level import not at top of file
---> 33 from .table import Table, GroupedTable, asc, desc  # noqa: E402
     34 from .matrixtable import MatrixTable, GroupedMatrixTable  # noqa: E402
     35 from .expr import *  # noqa: F401,F403,E402

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/hail/table.py:8
      5 import pyspark
      6 from typing import Optional, Dict, Callable, Sequence
----> 8 from hail.expr.expressions import Expression, StructExpression, \
      9     BooleanExpression, expr_struct, expr_any, expr_bool, analyze, Indices, \
     10     construct_reference, to_expr, construct_expr, extract_refs_by_indices, \
     11     ExpressionException, TupleExpression, unify_all, NumericExpression, \
     12     StringExpression, CallExpression, CollectionExpression, DictExpression, \
     13     IntervalExpression, LocusExpression, NDArrayExpression, expr_stream
     14 from hail.expr.types import hail_type, tstruct, types_match, tarray, tset, dtypes_from_pandas
     15 from hail.expr.table_type import ttable

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/hail/expr/__init__.py:1
----> 1 from .types import (dtype, HailType, hail_type, is_container, is_compound, is_numeric, is_primitive,
      2                     types_match, tint, tint32, tint64, tfloat, tfloat32, tfloat64, tstr, tbool, tarray, tstream,
      3                     tndarray, tset, tdict, tstruct, tunion, ttuple, tinterval, tlocus, tcall, tvoid, tvariable,
      4                     hts_entry_schema)
      5 from .table_type import ttable
      6 from .matrix_type import tmatrix

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/hail/expr/types.py:17
     14 from hailtop.hail_frozenlist import frozenlist
     16 from .nat import NatBase, NatLiteral
---> 17 from .type_parsing import type_grammar, type_node_visitor
     18 from .. import genetics
     19 from ..typecheck import typecheck, typecheck_method, oneof, transformed

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/hail/expr/type_parsing.py:1
----> 1 from parsimonious import Grammar, NodeVisitor
      2 from hail.expr.nat import NatVariable
      3 from . import types

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/parsimonious/__init__.py:9
      1 """Parsimonious's public API. Import from here.
      2 
      3 Things may move around in modules deeper than this one.
      4 
      5 """
      6 from parsimonious.exceptions import (ParseError, IncompleteParseError,
      7                                      VisitationError, UndefinedLabel,
      8                                      BadGrammar)
----> 9 from parsimonious.grammar import Grammar, TokenGrammar
     10 from parsimonious.nodes import NodeVisitor, VisitationError, rule

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/parsimonious/grammar.py:14
     11 from six import (text_type, itervalues, iteritems, python_2_unicode_compatible, PY2)
     13 from parsimonious.exceptions import BadGrammar, UndefinedLabel
---> 14 from parsimonious.expressions import (Literal, Regex, Sequence, OneOf,
     15     Lookahead, Optional, ZeroOrMore, OneOrMore, Not, TokenMatcher,
     16     expression)
     17 from parsimonious.nodes import NodeVisitor
     18 from parsimonious.utils import evaluate_string

File /usr/local/Cellar/jupyterlab/3.6.1/libexec/lib/python3.11/site-packages/parsimonious/expressions.py:9
      1 """Subexpressions that make up a parsed grammar
      2 
      3 These do the parsing.
      4 
      5 """
      6 # TODO: Make sure all symbol refs are local--not class lookups or
      7 # anything--for speed. And kill all the dots.
----> 9 from inspect import getargspec
     10 import re
     12 from six import integer_types, python_2_unicode_compatible

ImportError: cannot import name 'getargspec' from 'inspect' (/usr/local/Cellar/python@3.11/3.11.2_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/inspect.py)
danking pushed a commit to danking/hail that referenced this issue Mar 7, 2023
CHANGELOG: Update parsimonious to a verison that supports Python 3.11.

Fixes hail-is#12759.
@danking
Copy link
Contributor

danking commented Mar 7, 2023

Hey @dlcotter ! Thanks for the report. I anticipate a fix in the next version of Hail. For now, I think you can fix with pip3 install 'parsimonious>=0.9' or downgrading to Python 3.10

danking added a commit that referenced this issue Mar 7, 2023
CHANGELOG: Update parsimonious to a verison that supports Python 3.11.

Fixes #12759.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants