Skip to content
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

Fails on Python 3.7, can't import Literal from typing #13

Open
ahwillia opened this issue Jul 7, 2023 · 1 comment
Open

Fails on Python 3.7, can't import Literal from typing #13

ahwillia opened this issue Jul 7, 2023 · 1 comment

Comments

@ahwillia
Copy link
Owner

ahwillia commented Jul 7, 2023

Recently had to downgrade Python to 3.7 for some reason and ran into this.

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

~/code/netrep/netrep/metrics/__init__.py in <module>
      1 from netrep.metrics.cka import LinearCKA
----> 2 from netrep.metrics.linear import LinearMetric
      3 from netrep.metrics.perm import PermutationMetric
      4 from netrep.metrics.stochastic import GaussianStochasticMetric
      5 from netrep.metrics.stochastic import EnergyStochasticMetric

~/code/netrep/netrep/metrics/linear.py in <module>
      1 from __future__ import annotations
----> 2 from typing import Literal, Tuple
      3 
      4 import numpy as np
      5 import numpy.typing as npt

ImportError: cannot import name 'Literal' from 'typing' (/mnt/home/awilliams/anaconda3/envs/allensdk/lib/python3.7/typing.py)

We should specify our requirements better, or figure out a way to support Python 3.7

@talmo
Copy link

talmo commented Aug 14, 2023

You'll need to add typing_extensions to your deps, and then:

try:
    from typing import Literal
except ImportError:
    from typing_extensions import Literal

Ref: https://stackoverflow.com/a/67193166/1939934

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

No branches or pull requests

2 participants