Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python: Bug: ImportError: cannot import name 'Url' from 'pydantic.networks' since pydantic 2.10.0 release #9777

Open
Druid-of-Luhn opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code python Pull requests for the Python Semantic Kernel triage

Comments

@Druid-of-Luhn
Copy link

Describe the bug

The error ImportError: cannot import name 'Url' from 'pydantic.networks' (/usr/local/lib/python3.12/site-packages/pydantic/networks.py) is caused by from semantic_kernel import Kernel with pydantic==2.10.0.

This did not happen yesterday, with no changes to the code. It appears to be caused by pydantic version 2.10.0, which was released on 2024-11-20. This was noticed when building a Docker image that did not specify a pydantic version, and therefore used the latest one as a dependency to semantic-kernel.

Forcing pydantic==2.9.2 resolves the issue.

To Reproduce

Steps to reproduce the behavior:

mkdir pydantic-networks-bug
cd pydantic-networks-bug
python -m venv venv
.\venv\Scripts\activate
python -m pip install --upgrade pip
pip install semantic-kernel==1.15.0
python -c "from semantic_kernel import Kernel"

Expected behavior

No errors on from semantic_kernel import Kernel as long as the semantic-kernel package is installed.

Screenshots

Stack trace:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/app/my_module/processes/my_process/localruntime.py", line 11, in <module>
    from semantic_kernel import Kernel
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/__init__.py", line 3, in <module>
    from semantic_kernel.kernel import Kernel
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/kernel.py", line 8, in <module>
    from semantic_kernel.connectors.ai.embeddings.embedding_generator_base import EmbeddingGeneratorBase
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/connectors/ai/__init__.py", line 3, in <module>
    from semantic_kernel.connectors.ai.prompt_execution_settings import PromptExecutionSettings
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/connectors/ai/prompt_execution_settings.py", line 8, in <module>
    from semantic_kernel.connectors.ai.function_choice_behavior import FunctionChoiceBehavior
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/connectors/ai/function_choice_behavior.py", line 10, in <module>
    from semantic_kernel.connectors.ai.function_calling_utils import _combine_filter_dicts
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/connectors/ai/function_calling_utils.py", line 6, in <module>
    from semantic_kernel.contents.chat_message_content import ChatMessageContent
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/contents/__init__.py", line 3, in <module>
    from semantic_kernel.contents.annotation_content import AnnotationContent
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/contents/annotation_content.py", line 10, in <module>
    from semantic_kernel.contents.kernel_content import KernelContent
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/contents/kernel_content.py", line 8, in <module>
    from semantic_kernel.kernel_pydantic import KernelBaseModel
  File "/usr/local/lib/python3.12/site-packages/semantic_kernel/kernel_pydantic.py", line 7, in <module>
    from pydantic.networks import Url
ImportError: cannot import name 'Url' from 'pydantic.networks' (/usr/local/lib/python3.12/site-packages/pydantic/networks.py)

Platform

  • OS: Windows
  • IDE: gVim + PowerShell
  • Language: Python
  • Source: pip package version 1.15.0

Additional context

(none)

@Druid-of-Luhn Druid-of-Luhn added the bug Something isn't working label Nov 21, 2024
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code python Pull requests for the Python Semantic Kernel triage labels Nov 21, 2024
@github-actions github-actions bot changed the title Bug: ImportError: cannot import name 'Url' from 'pydantic.networks' since pydantic 2.10.0 release Python: Bug: ImportError: cannot import name 'Url' from 'pydantic.networks' since pydantic 2.10.0 release Nov 21, 2024
@github-actions github-actions bot changed the title Python: Bug: ImportError: cannot import name 'Url' from 'pydantic.networks' since pydantic 2.10.0 release .Net: Bug: ImportError: cannot import name 'Url' from 'pydantic.networks' since pydantic 2.10.0 release Nov 21, 2024
@Druid-of-Luhn Druid-of-Luhn changed the title .Net: Bug: ImportError: cannot import name 'Url' from 'pydantic.networks' since pydantic 2.10.0 release Python: Bug: ImportError: cannot import name 'Url' from 'pydantic.networks' since pydantic 2.10.0 release Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working .NET Issue or Pull requests regarding .NET code python Pull requests for the Python Semantic Kernel triage
Projects
None yet
Development

No branches or pull requests

2 participants