[Bug]: ImportError: cannot import name 'TypeIs' from 'typing_extensions'
otonoton opened this issue · 3 comments
Checklist
- The issue exists after disabling all extensions
- The issue exists on a clean installation of webui
- The issue is caused by an extension, but I believe it is caused by a bug in the webui
- The issue exists in the current version of the webui
- The issue has not been reported before recently
- The issue has been reported before but has not been fixed yet
What happened?
Building at least the auto-cpu
image fails with:
ImportError: cannot import name 'TypeIs' from 'typing_extensions' (/opt/conda/lib/python3.10/site-packages/typing_extensions.py)
The linked discussion suggests modifying the Dockerfile to update the typing_extensions
module to a newer version, which fixes the issue.
Steps to reproduce the problem
docker compose --profile auto-cpu up --build
What should have happened?
Build should not fail with an ImportError
What browsers do you use to access the UI ?
No response
Sysinfo
n/a
Console logs
$ docker compose --profile auto-cpu up --build
[+] Building 0.8s (26/26) FINISHED docker:default
=> [auto-cpu internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.96kB 0.0s
=> WARN: FromAsCasing: 'as' and 'FROM' keywords' casing do not match (line 1) 0.0s
=> [auto-cpu internal] load metadata for docker.io/pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime 0.8s
=> [auto-cpu internal] load metadata for docker.io/alpine/git:2.36.2 0.8s
=> [auto-cpu internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [auto-cpu download 1/9] FROM docker.io/alpine/git:2.36.2@sha256:ec491c893597b68c92b88023827faa771772cfd5e106b76c713fa5e1c75dea84 0.0s
=> [auto-cpu stage-1 1/11] FROM docker.io/pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime@sha256:0279f7aa29974bf64e61d0ff6e979b41a249b3662a46e30778dbf80b8c99c361 0.0s
=> [auto-cpu internal] load build context 0.0s
=> => transferring context: 122B 0.0s
=> CACHED [auto-cpu stage-1 2/11] RUN --mount=type=cache,target=/var/cache/apt apt-get update && apt-get install -y fonts-dejavu-core rsync git jq moreutils aria2 ffmpeg libglfw3-dev libgles2-mesa-dev pkg-config libcairo2 libcairo2-dev build-essential 0.0s
=> CACHED [auto-cpu stage-1 3/11] RUN --mount=type=cache,target=/root/.cache/pip git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && cd stable-diffusion-webui && git reset --hard v1.9.4 && pip install -r requirements_versions.txt 0.0s
=> CACHED [auto-cpu download 2/9] COPY clone.sh /clone.sh 0.0s
=> CACHED [auto-cpu download 3/9] RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets.git 6f7db241d2f8ba7457bac5ca9753331f0c266917 0.0s
=> CACHED [auto-cpu download 4/9] RUN . /clone.sh stable-diffusion-stability-ai https://github.com/Stability-AI/stablediffusion.git cf1d67a6fd5ea1aa600c4df58e5b47da45f6bdbf && rm -rf assets data/**/*.png data/**/*.jpg data/**/*.gif 0.0s
=> CACHED [auto-cpu download 5/9] RUN . /clone.sh BLIP https://github.com/salesforce/BLIP.git 48211a1594f1321b00f14c9f7a5b4813144b2fb9 0.0s
=> CACHED [auto-cpu download 6/9] RUN . /clone.sh k-diffusion https://github.com/crowsonkb/k-diffusion.git ab527a9a6d347f364e3d185ba6d714e22d80cb3c 0.0s
=> CACHED [auto-cpu download 7/9] RUN . /clone.sh clip-interrogator https://github.com/pharmapsychotic/clip-interrogator 2cf03aaf6e704197fd0dae7c7f96aa59cf1b11c9 0.0s
=> CACHED [auto-cpu download 8/9] RUN . /clone.sh generative-models https://github.com/Stability-AI/generative-models 45c443b316737a4ab6e40413d7794a7f5657c19f 0.0s
=> CACHED [auto-cpu download 9/9] RUN . /clone.sh stable-diffusion-webui-assets https://github.com/AUTOMATIC1111/stable-diffusion-webui-assets 6f7db241d2f8ba7457bac5ca9753331f0c266917 0.0s
=> CACHED [auto-cpu stage-1 4/11] COPY --from=download /repositories/ /stable-diffusion-webui/repositories/ 0.0s
=> CACHED [auto-cpu stage-1 5/11] RUN mkdir /stable-diffusion-webui/interrogate && cp /stable-diffusion-webui/repositories/clip-interrogator/clip_interrogator/data/* /stable-diffusion-webui/interrogate 0.0s
=> CACHED [auto-cpu stage-1 6/11] RUN --mount=type=cache,target=/root/.cache/pip pip install pyngrok xformers==0.0.26.post1 git+https://github.com/TencentARC/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379 git+https://github.com/openai/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e 0.0s
=> CACHED [auto-cpu stage-1 7/11] RUN apt-get -y install libgoogle-perftools-dev && apt-get clean 0.0s
=> CACHED [auto-cpu stage-1 8/11] COPY . /docker 0.0s
=> CACHED [auto-cpu stage-1 9/11] RUN sed -i 's/in_app_dir = .*/in_app_dir = True/g' /opt/conda/lib/python3.10/site-packages/gradio/routes.py && git config --global --add safe.directory '*' 0.0s
=> CACHED [auto-cpu stage-1 10/11] WORKDIR /stable-diffusion-webui 0.0s
=> [auto-cpu] exporting to image 0.0s
=> => exporting layers 0.0s
=> => writing image sha256:4814be6cc59d08fdedcc1d08520acf5659e1dd88e0f88aa79cf48940c1010670 0.0s
=> => naming to docker.io/library/sd-auto:78 0.0s
=> [auto-cpu] resolving provenance for metadata file 0.0s
[+] Running 2/1
✔ Network webui-docker_default Created 0.1s
✔ Container webui-docker-auto-cpu-1 Created 0.0s
Attaching to auto-cpu-1
auto-cpu-1 | /stable-diffusion-webui
auto-cpu-1 | total 772K
auto-cpu-1 | drwxr-xr-x 1 root root 4.0K Oct 1 21:20 .
auto-cpu-1 | drwxr-xr-x 1 root root 4.0K Oct 1 21:46 ..
auto-cpu-1 | -rw-r--r-- 1 root root 48 Oct 1 21:19 .eslintignore
auto-cpu-1 | -rw-r--r-- 1 root root 3.4K Oct 1 21:19 .eslintrc.js
auto-cpu-1 | drwxr-xr-x 8 root root 4.0K Oct 1 21:19 .git
auto-cpu-1 | -rw-r--r-- 1 root root 55 Oct 1 21:19 .git-blame-ignore-revs
auto-cpu-1 | drwxr-xr-x 4 root root 4.0K Oct 1 21:19 .github
auto-cpu-1 | -rw-r--r-- 1 root root 521 Oct 1 21:19 .gitignore
auto-cpu-1 | -rw-r--r-- 1 root root 119 Oct 1 21:19 .pylintrc
auto-cpu-1 | -rw-r--r-- 1 root root 84K Oct 1 21:19 CHANGELOG.md
auto-cpu-1 | -rw-r--r-- 1 root root 243 Oct 1 21:19 CITATION.cff
auto-cpu-1 | -rw-r--r-- 1 root root 657 Oct 1 21:19 CODEOWNERS
auto-cpu-1 | -rw-r--r-- 1 root root 35K Oct 1 21:19 LICENSE.txt
auto-cpu-1 | -rw-r--r-- 1 root root 13K Oct 1 21:19 README.md
auto-cpu-1 | -rw-r--r-- 1 root root 146 Oct 1 21:19 _typos.toml
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 configs
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 embeddings
auto-cpu-1 | -rw-r--r-- 1 root root 167 Oct 1 21:19 environment-wsl2.yaml
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 extensions
auto-cpu-1 | drwxr-xr-x 13 root root 4.0K Oct 1 21:19 extensions-builtin
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 html
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:20 interrogate
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 javascript
auto-cpu-1 | -rw-r--r-- 1 root root 1.3K Oct 1 21:19 launch.py
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 localizations
auto-cpu-1 | drwxr-xr-x 7 root root 4.0K Oct 1 21:19 models
auto-cpu-1 | drwxr-xr-x 7 root root 4.0K Oct 1 21:19 modules
auto-cpu-1 | -rw-r--r-- 1 root root 185 Oct 1 21:19 package.json
auto-cpu-1 | -rw-r--r-- 1 root root 841 Oct 1 21:19 pyproject.toml
auto-cpu-1 | drwxr-xr-x 8 root root 4.0K Oct 1 21:16 repositories
auto-cpu-1 | -rw-r--r-- 1 root root 49 Oct 1 21:19 requirements-test.txt
auto-cpu-1 | -rw-r--r-- 1 root root 371 Oct 1 21:19 requirements.txt
auto-cpu-1 | -rw-r--r-- 1 root root 42 Oct 1 21:19 requirements_npu.txt
auto-cpu-1 | -rw-r--r-- 1 root root 645 Oct 1 21:19 requirements_versions.txt
auto-cpu-1 | -rw-r--r-- 1 root root 411K Oct 1 21:19 screenshot.png
auto-cpu-1 | -rw-r--r-- 1 root root 6.1K Oct 1 21:19 script.js
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 scripts
auto-cpu-1 | -rw-r--r-- 1 root root 43K Oct 1 21:19 style.css
auto-cpu-1 | drwxr-xr-x 4 root root 4.0K Oct 1 21:19 test
auto-cpu-1 | drwxr-xr-x 2 root root 4.0K Oct 1 21:19 textual_inversion_templates
auto-cpu-1 | -rw-r--r-- 1 root root 670 Oct 1 21:19 webui-macos-env.sh
auto-cpu-1 | -rw-r--r-- 1 root root 84 Oct 1 21:19 webui-user.bat
auto-cpu-1 | -rw-r--r-- 1 root root 1.4K Oct 1 21:19 webui-user.sh
auto-cpu-1 | -rw-r--r-- 1 root root 2.3K Oct 1 21:19 webui.bat
auto-cpu-1 | -rw-r--r-- 1 root root 5.3K Oct 1 21:19 webui.py
auto-cpu-1 | -rwxr-xr-x 1 root root 11K Oct 1 21:19 webui.sh
auto-cpu-1 | ./
auto-cpu-1 | model.pt
auto-cpu-1 | ./
auto-cpu-1 | ViT-L-14_stats.th
auto-cpu-1 | Mounted .cache
auto-cpu-1 | mkdir: created directory '/data/config/auto/config_states'
auto-cpu-1 | Mounted config_states
auto-cpu-1 | mkdir: created directory '/stable-diffusion-webui/repositories/CodeFormer'
auto-cpu-1 | mkdir: created directory '/stable-diffusion-webui/repositories/CodeFormer/weights'
auto-cpu-1 | Mounted .cache
auto-cpu-1 | Mounted embeddings
auto-cpu-1 | Mounted config.json
auto-cpu-1 | Mounted models
auto-cpu-1 | Mounted styles.csv
auto-cpu-1 | Mounted ui-config.json
auto-cpu-1 | mkdir: created directory '/data/config/auto/extensions'
auto-cpu-1 | Mounted extensions
auto-cpu-1 | Installing extension dependencies (if any)
auto-cpu-1 | Traceback (most recent call last):
auto-cpu-1 | File "/stable-diffusion-webui/webui.py", line 13, in <module>
auto-cpu-1 | initialize.imports()
auto-cpu-1 | File "/stable-diffusion-webui/modules/initialize.py", line 23, in imports
auto-cpu-1 | import gradio # noqa: F401
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/gradio/__init__.py", line 3, in <module>
auto-cpu-1 | import gradio.components as components
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/gradio/components/__init__.py", line 3, in <module>
auto-cpu-1 | from gradio.components.bar_plot import BarPlot
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/gradio/components/bar_plot.py", line 7, in <module>
auto-cpu-1 | import altair as alt
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/altair/__init__.py", line 650, in <module>
auto-cpu-1 | from altair.vegalite import *
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/altair/vegalite/__init__.py", line 2, in <module>
auto-cpu-1 | from .v5 import *
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/altair/vegalite/v5/__init__.py", line 2, in <module>
auto-cpu-1 | from altair.expr.core import datum
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/altair/expr/__init__.py", line 7, in <module>
auto-cpu-1 | from altair.expr.core import ConstExpression, FunctionExpression
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/altair/expr/core.py", line 6, in <module>
auto-cpu-1 | from altair.utils import SchemaBase
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/altair/utils/__init__.py", line 14, in <module>
auto-cpu-1 | from .plugin_registry import PluginRegistry
auto-cpu-1 | File "/opt/conda/lib/python3.10/site-packages/altair/utils/plugin_registry.py", line 6, in <module>
auto-cpu-1 | from typing_extensions import TypeAliasType, TypeIs, TypeVar
auto-cpu-1 | ImportError: cannot import name 'TypeIs' from 'typing_extensions' (/opt/conda/lib/python3.10/site-packages/typing_extensions.py)
auto-cpu-1 exited with code 1
### Additional information
_No response_
I think this is the root cause for AbdBarho/stable-diffusion-webui-docker#742
Lots of people (including myself) reporting that a workaround is to install the additional missing library by changing the Dockerfile as follows (notice the pip install --upgrade typing-extensions
part):
> git diff services/AUTOMATIC1111/Dockerfile
diff --git a/services/AUTOMATIC1111/Dockerfile b/services/AUTOMATIC1111/Dockerfile
index d595784..47f75d0 100644
--- a/services/AUTOMATIC1111/Dockerfile
+++ b/services/AUTOMATIC1111/Dockerfile
@@ -31,7 +31,8 @@ RUN --mount=type=cache,target=/root/.cache/pip \
git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git && \
cd stable-diffusion-webui && \
git reset --hard v1.9.4 && \
- pip install -r requirements_versions.txt
+ pip install -r requirements_versions.txt && \
+ pip install --upgrade typing-extensions
So this likely just needs a requirements_versions.txt
update?
This change also worked for me.
I think this is the root cause for AbdBarho/stable-diffusion-webui-docker#742
Indeed, and by the way many identical issues have been reported in that other repo:
AbdBarho/stable-diffusion-webui-docker#719
AbdBarho/stable-diffusion-webui-docker#722
AbdBarho/stable-diffusion-webui-docker#729
Good practice alert !! 👉 Rather than installing typing_extensions
at the Dockerfile
level, it should be added to the requirements.txt
file !!