autogen icon indicating copy to clipboard operation
autogen copied to clipboard

from autogen import AssistantAgent, UserProxyAgent Gives Circular Import error

Open walker-null-byte opened this issue 3 years ago • 32 comments

from autogen import AssistantAgent, UserProxyAgent ImportError: cannot import name 'AssistantAgent' from partially initialized module 'autogen' (most likely due to a circular import)

The above is the error message

walker-null-byte avatar Sep 27 '23 22:09 walker-null-byte

@walker-null-byte, thank you for the issue. But I am not able to reproduce your error. See video below. Can you please provide your full code (including filenames), commands you ran to install autogen, platform, python version, etc.

https://github.com/microsoft/autogen/assets/13227607/60b40f9a-fe14-4f47-82b7-9799dc32006b

gagb avatar Sep 28 '23 00:09 gagb

only the import part is enough to give me the error

For installing i used - pip install autogen[blendsearch] --break-system-packages

then when i got the circular import error, i used - pip install autogen --break-system-packages

I am using python 3.11.5

I am using Garuda Linux with kernel - 6.5.3-zen1-1-zen

NOTE: --break-system-packages is used to override the warnings of pacman, and in most cases it has no effect on python. Circular Import in my experience is not caused by the --break-system-packages tag, but i might be wrong.

Thank You

walker-null-byte avatar Sep 28 '23 00:09 walker-null-byte

@walker-null-byte, thank you, will try to reproduce! One more question:

how do you run this python statement?

from autogen import AssistantAgent, UserProxyAgent

Python notebook? Python interpreter in command line? Or you have a script on your disk? Note that running this statement in a file called autogen.py can result in a circular import error (see video below). So please double-check.

https://github.com/microsoft/autogen/assets/13227607/520c100d-f79b-4cfe-9b56-75288af10146

gagb avatar Sep 28 '23 01:09 gagb

OK yeaa i named it autogen.py... i feel really dumb rn lol. Thanks for the help!

walker-null-byte avatar Sep 28 '23 01:09 walker-null-byte

from autogen import AssistantAgent, UserProxyAgent, Completion, tune_data, eval_func, test_instance ImportError: cannot import name 'AssistantAgent' from 'autogen'

Ok i got this new issue now. Any idea if im doing anything dumb again?

walker-null-byte avatar Sep 28 '23 01:09 walker-null-byte

@walker-null-byte , Seems like an issue with setup. Are you able to reproduce your error in a fresh directory and install of AutoGen?

gagb avatar Sep 28 '23 17:09 gagb

sorry for the late reply. Yes i am getting the same error

walker-null-byte avatar Oct 01 '23 01:10 walker-null-byte

Same error here: ImportError: cannot import name 'AssistantAgent' from 'autogen'

DoriShabat avatar Oct 02 '23 17:10 DoriShabat

Is pip install pyautogen used to install the package?

sonichi avatar Oct 02 '23 18:10 sonichi

Yeah its possible you did pip install autogen instead of pip install pyautogen

gagb avatar Oct 02 '23 19:10 gagb

redoing pip install pyautogen fixes it for me, thanks!

walker-null-byte avatar Oct 03 '23 00:10 walker-null-byte

Im getting this issue. I have removed all, tested in new area. new environment. I have done the pip install autogen, ive have removed and done the pip install pyautogen. Still getting this error:

ImportError: cannot import name 'AssistantAgent' from 'autogen' from line 1 of my main.py file

CarlHodges avatar Oct 05 '23 09:10 CarlHodges

I'm having the same issue, uninstalled and re-installed. Tried in multiple venv too

akhilnchauhan avatar Oct 07 '23 01:10 akhilnchauhan

Same

Edit: Sorry, I named my file autogen.py which is dumb

CUexter avatar Oct 09 '23 21:10 CUexter

redoing pip install pyautogen fixes it for me too! Thanks

goforit5 avatar Oct 11 '23 18:10 goforit5

OK yeaa i named it autogen.py... i feel really dumb rn lol. Thanks for the help!

me too

Alnevis avatar Oct 19 '23 16:10 Alnevis

had a similar error and had to uninstalled pyautogen and reinstalled pyautogen but first, I upgraded my version of Pip before I reinstalled pyautogen and it works fine now. [notice] A new release of pip available: 22.3.1 -> 23.3 [notice] To update, run: python.exe -m pip install --upgrade pip cmd: python.exe -m pip install --upgrade pip

JTedam avatar Oct 20 '23 07:10 JTedam

may be you can use Virtual Environment

python3 -m venv autogen source autogen/bin/activate pip install pyautogen

erdogancayir avatar Oct 20 '23 19:10 erdogancayir

You don't use both import autoagen and from autogen import AssistantAgenton the same page. Your file name must not autoagen.py.

erdogancayir avatar Oct 20 '23 20:10 erdogancayir

installing pyautogen instead of autogen did the trick for me. thanks!

rolme avatar Oct 23 '23 23:10 rolme