换脸插件升级导致SDWebUI无法启动cannot import name ‘Undefined‘ from ‘pydantic.fields‘

时间:2024-04-27 07:43:38

今天在一台新的机器环境装了SDWEBUI,都使用最新的版本,升级了下换脸的插件,于是乎启动崩溃了。错误如下

Launching Web UI with arguments: --listen --skip-torch-cuda-test --disable-nan-check --skip-version-check --skip-python-version-check --enable-insecure-extension-access --api --xformers --xformers-flash-attention --opt-sdp-attention --no-half-vae --ad-no-huggingface --theme=dark --lora-dir /mnt/e/sddata/Lora --vae-dir /mnt/e/sddata/VAE --ckpt-dir /mnt/e/sddata/checkpoint --controlnet-dir /mnt/e/sddata/ControlNet --embeddings-dir /mnt/e/sddata/embeddings --controlnet-annotator-models-path /mnt/e/sddata/downloads
Traceback (most recent call last):
  File "/mnt/e/sd-webui-aki-v4.7/launch.py", line 48, in <module>
    main()
  File "/mnt/e/sd-webui-aki-v4.7/launch.py", line 44, in main
    start()
  File "/mnt/e/sd-webui-aki-v4.7/modules/launch_utils.py", line 465, in start
    import webui
  File "/mnt/e/sd-webui-aki-v4.7/webui.py", line 13, in <module>
    initialize.imports()
  File "/mnt/e/sd-webui-aki-v4.7/modules/initialize.py", line 23, in imports
    import gradio  # noqa: F401
    ^^^^^^^^^^^^^
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/gradio/__init__.py", line 3, in <module>
    import gradio.components as components
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/gradio/components/__init__.py", line 1, in <module>
    from gradio.components.annotated_image import AnnotatedImage
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/gradio/components/annotated_image.py", line 13, in <module>
    from gradio.components.base import IOComponent, _Keywords
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/gradio/components/base.py", line 20, in <module>
    from fastapi import UploadFile
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/fastapi/__init__.py", line 7, in <module>
    from .applications import FastAPI as FastAPI
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/fastapi/applications.py", line 15, in <module>
    from fastapi import routing
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/fastapi/routing.py", line 22, in <module>
    from fastapi import params
  File "/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/fastapi/params.py", line 4, in <module>
    from pydantic.fields import FieldInfo, Undefined
ImportError: cannot import name 'Undefined' from 'pydantic.fields' (/mnt/e/sd-webui-aki-v4.7/venv/lib/python3.11/site-packages/pydantic/fields.py)

google了下是pydantic要使用1.10.15版本

于是乎降级pydantic,发现gradio和albumentations又报错了,因为依赖最新的版本,结果还得给gradio和albumentations降级。降级到去年年底的版本

折腾了一个小时。。。。。降级后错误依旧,没道理

冷静。。。。。

索性uninstall掉gradio,发现错误依旧。。。。

有点头绪了,怎么没uninstall掉,仔细看了下目录,里面还有个坑爹的venv,再进去看,gradio还是原来的版本。有头绪了,估计我使用的conda环境对venv没作用

source /mnt/e/sd-webui-aki-v4.7/venv/bin/activate
一下,进去venv了

把降级的操作重做一遍:

pip uninstall pydantic
pip uninstall gradio 
pip uninstall albumentations

pip install pydantic==1.10.15
pip install gradio==3.50.2
pip install albumentations==1.3.1

然后启动sd。。。

熟悉的界面终于出来了,内牛满面