AG2 0.5 upgrade breaks `from autogen import ...` — how to fix?
After upgrading the ag2 Python package from 0.41 to 0.5 with
pip install ag2 --upgrade, imports such asfrom autogen import SwarmResult, AssistantAgent, SwarmAgentandfrom autogen.coding import DockerCommandLineCodeExecutorstarted failing. What caused the breakage and how do I restore the imports?Originally asked on GitHub: https://github.com/ag2ai/ag2/issues/169
3 answers
Status: fixed. The issue was closed as completed after the reporter ran a maintainer-suggested uninstall/reinstall that restored the imports.
Maintainer @marklysze suggested running:
bashpip uninstall openai pyautogen ag2 pip install ag2The issue author confirmed this worked and that they no longer had import issues. They were upgrading from AG2 0.41 and were not sure whether pyautogen was also installed; the thread does not identify the exact cause of the broken imports.
As an alternative, one commenter reported that using the
pyautogenpackage instead ofag2also works. The maintainers also asked for the full traceback and which package manager was being used, but the uninstall/reinstall was reported as sufficient. As general advice, if imports still fail after a clean reinstall, check whether any other installed package provides anautogentop-level module.Did this work for you?What @bassilkhilo tried on GitHub (Worked)
Ran
pip uninstall openai pyautogen ag2followed bypip install ag2as suggested by maintainer @marklysze. The reporter confirmed the import issues were gone.Source: https://github.com/ag2ai/ag2/issues/169#issuecomment-2526505029 (opens external site)
Did this work for you?What @ashim-mahara tried on GitHub (Worked)
A commenter reported that using the
pyautogenpackage works as an alternative.Source: https://github.com/ag2ai/ag2/issues/169#issuecomment-2526342561 (opens external site)
Did this work for you?
Related questions
- How to use context variables in AG2 OnCondition handoff strings?
- AG2 + Gemini function calling: 400 "function response turn must come immediately after a function call turn"
- ag2 LLMConfig.where(tags='tool') fails when tags is a list in OAI_CONFIG_LIST
- How to get structured outputs from Bedrock in ag2 when response_format is ignored?
- Does AG2 support remote/distributed agents (A2A)?