Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

Import error on Python version 3.10.X #1022

@aakash-sahai

Description

@aakash-sahai

I am running Python 3.10.12 (on MacOS M1). Upon importing graphql_compiler, I get the following error:

Stacktrace

>>> from graphql_compiler import graphql_to_sql
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/asahai/repos/cat/.venv/lib/python3.10/site-packages/graphql_compiler/__init__.py", line 3, in <module>
    from .compiler import (  # noqa
  File "/Users/asahai/repos/cat/.venv/lib/python3.10/site-packages/graphql_compiler/compiler/__init__.py", line 2, in <module>
    from .common import (  # noqa
  File "/Users/asahai/repos/cat/.venv/lib/python3.10/site-packages/graphql_compiler/compiler/common.py", line 4, in <module>
    from . import (
  File "/Users/asahai/repos/cat/.venv/lib/python3.10/site-packages/graphql_compiler/compiler/emit_cypher.py", line 3, in <module>
    from .blocks import Fold, QueryRoot, Recurse, Traverse
  File "/Users/asahai/repos/cat/.venv/lib/python3.10/site-packages/graphql_compiler/compiler/blocks.py", line 7, in <module>
    from .helpers import (
  File "/Users/asahai/repos/cat/.venv/lib/python3.10/site-packages/graphql_compiler/compiler/helpers.py", line 4, in <module>
    from collections import Hashable, namedtuple
ImportError: cannot import name 'Hashable' from 'collections' (/opt/homebrew/Cellar/python@3.10/3.10.12_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)

Steps to reproduce

from graphql_compiler import graphql_to_sql

How to fix

The Hashtable has been moved to collections.abc from Python 3.3 onwards, so the fix is to break up the above import into two imports as follows:

from collections import namedtuple
from collections.abc import Hashable

Version error is found

graphql-compiler 1.11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions