Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I ran into:

ImportError: cannot import name 'TypeAlias' from 'typing' (/opt/homebrew/Caskroom/miniconda/base/envs/ldm/lib/python3.9/typing.py)



I followed the conda instruction which uses Python 3.9 and ran into the same issue. The workaround is to import TypeAlias from typing_extensions:

stable-diffusion/src/k-diffusion/k_diffusion/sampling.py

(before)

  from typing import Optional, Callable, TypeAlias
(after)

  from typing import Optional, Callable
  from typing_extensions import TypeAlias
This issue is tracked in https://github.com/lstein/stable-diffusion/issues/302


you can also just change the python version in the yml file to 3.10.4 and it'll work


I ran into this. You need Python 3.10. I had to edit environment-mac.yaml and set python==3.10.6 ...


I changed the dependency to 3.10.4 (tried 3.10.6 as well), installed python 3.10.4, deactivated and activated ldm environment, but it still uses python 3.9


Can you delete your environment and try again?


Since I don't know how to use conda, I had to struggle a bit to learn how to recreate the environment. Here's the commands that worked me for future reference:

  conda deactivate
  conda env remove -n ldm
Then, again:

  CONDA_SUBDIR=osx-arm64 conda env create -f environment-mac.yaml
  conda activate ldm


Thanks, it worked


This worked for me too.


TypeAlias is only used once, you can open sampling.py and remove the import on line 10 and the usage on line 14:

  from typing import Optional, Callable

  from . import utils

  TensorOperator = Callable[[Tensor], Tensor]




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: