lllyasviel / ControlNet

Let us control diffusion models!
Apache License 2.0
28.94k stars 2.61k forks source link

cannot import name 'Undefined' from 'pydantic.fields' Error #671

Open afk22 opened 2 months ago

afk22 commented 2 months ago

I can use stable diffusion without any problems. However, whenever I try to install ControlNet, I encounter the error below and can't use the program. I've reinstalled the program from scratch, but it didn't fix the issue. I tried "pip install --upgrade pip" but it didn't work either. Most of the solutions I found online didn't help.

File "C:\Users\AFK\Downloads\sd.webui\system\python\lib\site-packages\fastapi\params.py", line 4, in from pydantic.fields import FieldInfo, Undefined ImportError: cannot import name 'Undefined' from 'pydantic.fields' (C:\Users\AFK\Downloads\sd.webui\system\python\lib\site-packages\pydantic\fields.py) Press any key to continue . . .

carlosjandro commented 2 months ago

Hi @afk22! I had the same problem and someone awesome helps me with this in a Discord group, it works!!!

  1. First of all you need to have pip installed.
  2. Open and explorer window and go to the folder of your SD ...\stable-diffusion-webui\venv\Scripts
  3. Type "CMD" in the address bar.
  4. Write in the console: activate
  5. Write: cd.. two times to arrive at your stable-diffusion-webui directory
  6. Write: pip install -r requirements.txt

And that´s all! I hope it works :)

afk22 commented 2 months ago

Hi @carlosjandro , thank you for the solution. It worked perfectly!