Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ImportError: cannot import name 'MultiHostDsn' from 'pydantic.networks' #6578

Description

@KyriakiGeorgiou

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

I am using gradio to dispaly my NLP model. On Friday it was working perfectly, but after the new release (gradio v3.36.1 and pydantic v2.02 or any other I use) whenever I run any code with the gradio import I get the following error: "/usr/local/lib/python3.10/dist-packages/fastapi/_compat.py in
295 UndefinedType as UndefinedType, # noqa: F401
296 )
--> 297 from pydantic.networks import ( # type: ignore[no-redef]
298 MultiHostDsn as MultiHostUrl, # noqa: F401
299 )

ImportError: cannot import name 'MultiHostDsn' from 'pydantic.networks' (/usr/local/lib/python3.10/dist-packages/pydantic/networks.cpython-310-x86_64-linux-gnu.so)". Even when I run the code with a simple example like the following and no extra imports I still get the same error.

Example Code

import pydantic
import gradio as gr
def sketch_recognition(img):
    pass# Implement your sketch recognition model here...

gr.Interface(fn=sketch_recognition, inputs="sketchpad", outputs="label").launch()

Python, Pydantic & OS Version

pydantic version: 2.0.2
        pydantic-core version: 2.1.2 release build profile
                 install path: /usr/local/lib/python3.10/dist-packages/pydantic
               python version: 3.10.12 (main, Jun  7 2023, 12:45:35) [GCC 9.4.0]
                     platform: Linux-5.15.107+-x86_64-with-glibc2.31
     optional deps. installed: ['typing-extensions']

Selected Assignee: @lig

Metadata

Metadata

Assignees

Labels

bug V2Bug related to Pydantic V2pendingIs unconfirmed

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions