vladmandic / automatic

SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models
https://github.com/vladmandic/automatic
GNU Affero General Public License v3.0
5.36k stars 382 forks source link

[Issue]: ImportError: cannot import name 'Doc' from 'typing_extensions' #2334

Closed klausman closed 9 months ago

klausman commented 9 months ago

Issue Description

fresh checkout made with git clone --recursive https://github.com/vladmandic/automatic vladmatic

No existing config.json or ui-config.json. webui-user.sh only changes the TMPDIR/TEMPDIR variables. Model dirs for SD, Lora and VAE contain a bunch of downloads.

Version Platform Description

Linux, Debian testing (trixie).

Relevant log output

$ ./webui.sh --debug --listen --insecure
Create and activate python venv
Launching launch.py...
16:01:59-155890 DEBUG    Logger: file=/home/klausman/q/news/vladmatic/sdnext.log level=10 size=0 mode=create                                                                                            
16:01:59-157855 INFO     Starting SD.Next                                                                                                                                                               
16:01:59-158382 INFO     Python 3.10.13 on Linux                                                                                                                                                        
16:01:59-166214 INFO     Version: app=sd.next updated=2023-10-18 hash=f6486496 url=https://github.com/vladmandic/automatic/tree/master                                                                  
16:01:59-410393 INFO     Platform: arch=x86_64 cpu= system=Linux release=6.5.0-1-amd64 python=3.10.13                                                                                                   
16:01:59-411308 DEBUG    Setting environment tuning                                                                                                                                                     
16:01:59-411792 DEBUG    Torch overrides: cuda=False rocm=False ipex=False diml=False openvino=False                                                                                                    
16:01:59-412371 DEBUG    Torch allowed: cuda=True rocm=True ipex=True diml=True openvino=True                                                                                                           
16:01:59-412943 INFO     nVidia CUDA toolkit detected: nvidia-smi present                                                                                                                               
16:01:59-413377 INFO     Installing torch - this may take a while                                                                                                                                       
16:01:59-425500 DEBUG    Repository update time: Wed Oct 18 15:17:38 2023                                                                                                                               
16:01:59-426053 INFO     Verifying requirements                                                                                                                                                         
16:01:59-433604 INFO     Verifying packages                                                                                                                                                             
16:01:59-434639 INFO     Verifying repositories                                                                                                                                                         
16:01:59-439157 DEBUG    Submodule: /home/klausman/q/news/vladmatic/repositories/stable-diffusion-stability-ai / main                                                                                   
16:01:59-805964 DEBUG    Submodule: /home/klausman/q/news/vladmatic/repositories/taming-transformers / master                                                                                           
16:02:00-896164 DEBUG    Submodule: /home/klausman/q/news/vladmatic/repositories/BLIP / main                                                                                                            
16:02:01-268543 INFO     Verifying submodules                                                                                                                                                           
16:02:01-409569 DEBUG    Submodule: extensions-builtin/clip-interrogator-ext / main                                                                                                                     
16:02:01-414485 DEBUG    Submodule: extensions-builtin/sd-extension-chainner / main                                                                                                                     
16:02:01-420052 DEBUG    Submodule: extensions-builtin/sd-extension-system-info / main                                                                                                                  
16:02:01-425150 DEBUG    Submodule: extensions-builtin/sd-webui-agent-scheduler / main                                                                                                                  
16:02:01-430156 DEBUG    Submodule: extensions-builtin/sd-webui-controlnet / main                                                                                                                       
16:02:01-437521 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-images-browser / main                                                                                                     
16:02:01-442364 DEBUG    Submodule: extensions-builtin/stable-diffusion-webui-rembg / master                                                                                                            
16:02:01-447420 DEBUG    Submodule: modules/lora / main                                                                                                                                                 
16:02:01-452709 DEBUG    Submodule: wiki / master                                                                                                                                                       
16:02:01-483858 DEBUG    Installed packages: 212                                                                                                                                                        
16:02:01-484387 DEBUG    Extensions all: ['Lora', 'clip-interrogator-ext', 'sd-extension-chainner', 'sd-extension-system-info', 'sd-webui-agent-scheduler', 'sd-webui-controlnet',                      
                         'stable-diffusion-webui-images-browser', 'stable-diffusion-webui-rembg']                                                                                                       
16:02:01-512144 DEBUG    Running extension installer: /home/klausman/q/news/vladmatic/extensions-builtin/clip-interrogator-ext/install.py                                                               
16:02:04-151960 DEBUG    Running extension installer: /home/klausman/q/news/vladmatic/extensions-builtin/sd-extension-system-info/install.py                                                            
16:02:04-275400 DEBUG    Running extension installer: /home/klausman/q/news/vladmatic/extensions-builtin/sd-webui-agent-scheduler/install.py                                                            
16:02:04-397426 DEBUG    Running extension installer: /home/klausman/q/news/vladmatic/extensions-builtin/sd-webui-controlnet/install.py                                                                 
16:02:04-520224 DEBUG    Running extension installer: /home/klausman/q/news/vladmatic/extensions-builtin/stable-diffusion-webui-images-browser/install.py                                               
16:02:04-641808 DEBUG    Running extension installer: /home/klausman/q/news/vladmatic/extensions-builtin/stable-diffusion-webui-rembg/install.py                                                        
16:02:04-764207 DEBUG    Extensions all: []                                                                                                                                                             
16:02:04-764700 INFO     Extensions enabled: ['Lora', 'clip-interrogator-ext', 'sd-extension-chainner', 'sd-extension-system-info', 'sd-webui-agent-scheduler', 'sd-webui-controlnet',                  
                         'stable-diffusion-webui-images-browser', 'stable-diffusion-webui-rembg']                                                                                                       
16:02:04-765296 INFO     Verifying packages                                                                                                                                                             
16:02:04-766294 DEBUG    Setup complete without errors: 1697637725                                                                                                                                      
16:02:04-767964 INFO     Extension preload: {'extensions-builtin': 0.0, 'extensions': 0.0}                                                                                                              
16:02:04-768672 DEBUG    Starting module: <module 'webui' from '/home/klausman/q/news/vladmatic/webui.py'>                                                                                              
16:02:04-769310 INFO     Command line args: ['--debug', '--listen', '--insecure'] insecure=True listen=True debug=True                                                                                  
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/klausman/q/news/vladmatic/launch.py:215 in <module>                                        │
│                                                                                                  │
│   212 │   # installer.log.debug(f"Args: {vars(args)}")                                           │
│   213 │   logging.disable(logging.NOTSET if args.debug else logging.DEBUG)                       │
│   214 │                                                                                          │
│ ❱ 215 │   uv, instance = start_server(immediate=True, server=None)                               │
│   216 │   while True:                                                                            │
│   217 │   │   try:                                                                               │
│   218 │   │   │   alive = uv.thread.is_alive()                                                   │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/launch.py:147 in start_server                                    │
│                                                                                                  │
│   144 │   server = importlib.util.module_from_spec(module_spec)                                  │
│   145 │   installer.log.debug(f'Starting module: {server}')                                      │
│   146 │   get_custom_args()                                                                      │
│ ❱ 147 │   module_spec.loader.exec_module(server)                                                 │
│   148 │   uvicorn = None                                                                         │
│   149 │   if args.test:                                                                          │
│   150 │   │   installer.log.info("Test only")                                                    │
│ in exec_module:883                                                                               │
│ in _call_with_frames_removed:241                                                                 │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/webui.py:11 in <module>                                          │
│                                                                                                  │
│     8 import importlib                                                                           │
│     9 import contextlib                                                                          │
│    10 from threading import Thread                                                               │
│ ❱  11 import modules.loader                                                                      │
│    12 import torch # pylint: disable=wrong-import-order                                          │
│    13 from modules import timer, errors, paths # pylint: disable=unused-import                   │
│    14 local_url = None                                                                           │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/modules/loader.py:32 in <module>                                 │
│                                                                                                  │
│   29 warnings.filterwarnings(action="ignore", category=UserWarning, module="torchvision")        │
│   30 timer.startup.record("torch")                                                               │
│   31                                                                                             │
│ ❱ 32 from fastapi import FastAPI # pylint: disable=W0611,C0411                                   │
│   33 import gradio # pylint: disable=W0611,C0411                                                 │
│   34 timer.startup.record("gradio")                                                              │
│   35 errors.install([gradio])                                                                    │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/fastapi/__init__.py:7 in       │
│ <module>                                                                                         │
│                                                                                                  │
│    4                                                                                             │
│    5 from starlette import status as status                                                      │
│    6                                                                                             │
│ ❱  7 from .applications import FastAPI as FastAPI                                                │
│    8 from .background import BackgroundTasks as BackgroundTasks                                  │
│    9 from .datastructures import UploadFile as UploadFile                                        │
│   10 from .exceptions import HTTPException as HTTPException                                      │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/fastapi/applications.py:16 in  │
│ <module>                                                                                         │
│                                                                                                  │
│     13 │   Union,                                                                                │
│     14 )                                                                                         │
│     15                                                                                           │
│ ❱   16 from fastapi import routing                                                               │
│     17 from fastapi.datastructures import Default, DefaultPlaceholder                            │
│     18 from fastapi.exception_handlers import (                                                  │
│     19 │   http_exception_handler,                                                               │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/fastapi/routing.py:22 in       │
│ <module>                                                                                         │
│                                                                                                  │
│     19 │   Union,                                                                                │
│     20 )                                                                                         │
│     21                                                                                           │
│ ❱   22 from fastapi import params                                                                │
│     23 from fastapi._compat import (                                                             │
│     24 │   ModelField,                                                                           │
│     25 │   Undefined,                                                                            │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/fastapi/params.py:5 in         │
│ <module>                                                                                         │
│                                                                                                  │
│     2 from enum import Enum                                                                      │
│     3 from typing import Any, Callable, Dict, List, Optional, Sequence, Union                    │
│     4                                                                                            │
│ ❱   5 from fastapi.openapi.models import Example                                                 │
│     6 from pydantic.fields import FieldInfo                                                      │
│     7 from typing_extensions import Annotated, deprecated                                        │
│     8                                                                                            │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/fastapi/openapi/models.py:4 in │
│ <module>                                                                                         │
│                                                                                                  │
│     1 from enum import Enum                                                                      │
│     2 from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Type, Union         │
│     3                                                                                            │
│ ❱   4 from fastapi._compat import (                                                              │
│     5 │   PYDANTIC_V2,                                                                           │
│     6 │   CoreSchema,                                                                            │
│     7 │   GetJsonSchemaHandler,                                                                  │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/fastapi/_compat.py:20 in       │
│ <module>                                                                                         │
│                                                                                                  │
│    17 │   Union,                                                                                 │
│    18 )                                                                                          │
│    19                                                                                            │
│ ❱  20 from fastapi.exceptions import RequestErrorModel                                           │
│    21 from fastapi.types import IncEx, ModelNameMap, UnionType                                   │
│    22 from pydantic import BaseModel, create_model                                               │
│    23 from pydantic.version import VERSION as PYDANTIC_VERSION                                   │
│                                                                                                  │
│ /home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/fastapi/exceptions.py:6 in     │
│ <module>                                                                                         │
│                                                                                                  │
│     3 from pydantic import BaseModel, create_model                                               │
│     4 from starlette.exceptions import HTTPException as StarletteHTTPException                   │
│     5 from starlette.exceptions import WebSocketException as StarletteWebSocketException         │
│ ❱   6 from typing_extensions import Annotated, Doc  # type: ignore [attr-defined]                │
│     7                                                                                            │
│     8                                                                                            │
│     9 class HTTPException(StarletteHTTPException):                                               │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ImportError: cannot import name 'Doc' from 'typing_extensions' (/home/klausman/q/news/vladmatic/venv/lib/python3.10/site-packages/typing_extensions.py)

Backend

Diffusers

Model

SD-XL

Acknowledgements

Rinelw commented 9 months ago

It seems like it downloads the 4.7.1 version of typing_extensions.py which doesn't have a class called Doc download 4.8.0 version and it should work fine.

klausman commented 9 months ago

It seems like it downloads the 4.7.1 version of typing_extensions.py which doesn't have a class called Doc download 4.8.0 version and it should work fine.

Confirmed: changing requirements.txt as follows enables startup:

diff --git a/requirements.txt b/requirements.txt
index 7d5e41ae..e33e388f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -43,7 +43,7 @@ fasteners
 dctorch
 compel==2.0.2
 torchsde==0.2.6
-typing-extensions==4.7.1
+typing-extensions==4.8.0
 antlr4-python3-runtime==4.9.3
 requests==2.31.0
 tqdm==4.66.1
vladmandic commented 9 months ago

duplicate. please search before creating new issue.

klausman commented 9 months ago

I did. The dupe was filed between me searching and me getting all the info for this one.

vladmandic commented 9 months ago

fair enough.