4 ms·
I ran into: ImportError: cannot import name 'TypeAlias' from 'typing' (/opt/homebrew/Caskroom/miniconda/base/envs/ldm/lib/python3.9/typing.py)
by solarkraft 4y ago
I ran into:
ImportError: cannot import name 'TypeAlias' from 'typing' (/opt/homebrew/Caskroom/miniconda/base/envs/ldm/lib/python3.9/typing.py)
- icedchai 4y agoI ran into this. You need Python 3.10. I had to edit environment-mac.yaml and set python==3.10.6 ...
- kenrose 4y agoThis worked for me too.
- xiphias2 4y agoI 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
- icedchai 4y agoCan you delete your environment and try again?
- xiphias2 4y agoThanks, it worked
- hgo 4y agoSince 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
- itsuka 4y agoI 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 https://github.com/lstein/stable-diffusion/issues/302
- wincy 4y agoyou can also just change the python version in the yml file to 3.10.4 and it'll work
- personjerry 4y agoTypeAlias 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]