Skip to content

ImportError: cannot import name 'parse_obj_as' from 'pydantic' (/opt/conda/lib/python3.10/site-packages/pydantic/__init__.py) #746

@RashiqAzhan

Description

@RashiqAzhan

Has this issue been opened before?

  • It is not in the FAQ, I checked.
  • It is not in the issues, I searched.

Describe the bug

The container fails to run with the following error.

auto-cpu-1  | Traceback (most recent call last):
auto-cpu-1  |   File "/stable-diffusion-webui/./extensions/canvas-zoom/install.py", line 4, in <module>
auto-cpu-1  |     import gradio
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 1, in <module>
auto-cpu-1  |     from gradio.components.annotated_image import AnnotatedImage
auto-cpu-1  |   File "/opt/conda/lib/python3.10/site-packages/gradio/components/annotated_image.py", line 12, in <module>
auto-cpu-1  |     from gradio import utils
auto-cpu-1  |   File "/opt/conda/lib/python3.10/site-packages/gradio/utils.py", line 40, in <module>
auto-cpu-1  |     from pydantic import BaseModel, parse_obj_as
auto-cpu-1  | ImportError: cannot import name 'parse_obj_as' from 'pydantic' (/opt/conda/lib/python3.10/site-packages/pydantic/__init__.py)
auto-cpu-1 exited with code 1

I've put the following two lines inside the automatic1111 folder's dockerfile as suggested in other issues here and here.

WORKDIR /
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 --upgrade typing-extensions && \
  pip install -U pydantic==1

Which UI

auto-cpu.

Hardware / Software

  • OS: CachyOS Linux x86_64
  • OS version: rolling
  • Docker Version: 27.3.1
  • Docker compose version: 2.29.7
  • Repo version: 802d0bc, master, tag: 9.0.0
  • RAM: 64 GB
  • GPU/VRAM: N/A

Steps to Reproduce

  1. git clone or git reset --hard origin/master
  2. Add the following to fix the other issues that occur.

pip install --upgrade typing-extensions &&
pip install -U pydantic==1
```
3. docker compose --profile download up --build and `docker compose --profile auto-cpu up --build`
4. See error

Additional context
Adding pip install -U albumentations==1.4.3 in the dockerfile as stated here after the pydantic does not help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions