Skip to content

ImportError: cannot import name 'TypeAlias' from 'typing' on macOS #322

@asimilon

Description

@asimilon

After following the steps in README-Mac-MPS.md I get the following error:

(ldm) richelmes@M1mini:~/various/stable-diffusion
main 16:05 $ python scripts/dream.py --full_precision           
* Initializing, be patient...

Traceback (most recent call last):
  File "/Users/richelmes/various/stable-diffusion/scripts/dream.py", line 553, in <module>
    main()
  File "/Users/richelmes/various/stable-diffusion/scripts/dream.py", line 41, in main
    from ldm.simplet2i import T2I
  File "/Users/richelmes/various/stable-diffusion/ldm/simplet2i.py", line 29, in <module>
    from ldm.models.diffusion.ksampler import KSampler
  File "/Users/richelmes/various/stable-diffusion/ldm/models/diffusion/ksampler.py", line 2, in <module>
    import k_diffusion as K
  File "/Users/richelmes/various/stable-diffusion/src/k-diffusion/k_diffusion/__init__.py", line 1, in <module>
    from . import augmentation, config, evaluation, external, gns, layers, models, sampling, utils
  File "/Users/richelmes/various/stable-diffusion/src/k-diffusion/k_diffusion/external.py", line 6, in <module>
    from . import sampling, utils
  File "/Users/richelmes/various/stable-diffusion/src/k-diffusion/k_diffusion/sampling.py", line 10, in <module>
    from typing import Optional, Callable, TypeAlias
ImportError: cannot import name 'TypeAlias' from 'typing' (/opt/homebrew/anaconda3/envs/ldm/lib/python3.9/typing.py)

I tried:

pip uninstall typing_extensions
pip install typing_extensions==4.0.0
Found existing installation: typing_extensions 4.3.0
Uninstalling typing_extensions-4.3.0:
  Would remove:
    /opt/homebrew/anaconda3/envs/ldm/lib/python3.9/site-packages/typing_extensions-4.3.0.dist-info/*
    /opt/homebrew/anaconda3/envs/ldm/lib/python3.9/site-packages/typing_extensions.py
Proceed (Y/n)? y
  Successfully uninstalled typing_extensions-4.3.0
Collecting typing_extensions==4.0.0
  Using cached typing_extensions-4.0.0-py3-none-any.whl (22 kB)
Installing collected packages: typing_extensions
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
qudida 0.0.4 requires opencv-python-headless>=4.0.1, which is not installed.
albumentations 1.2.1 requires opencv-python-headless>=4.1.1, which is not installed.
Successfully installed typing_extensions-4.0.0

but still get the same error.

This was all working for me before pulling the latest version today, but I removed the ldm anaconda environment to be sure that everything was up to date and ran into problems, so I nuked everything and tried to install from scratch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions