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

ImportError: cannot import name 'AssistantAgent' from 'autogen' #705

Closed
CzzzzzzJ opened this issue Nov 17, 2023 · 18 comments
Closed

ImportError: cannot import name 'AssistantAgent' from 'autogen' #705

CzzzzzzJ opened this issue Nov 17, 2023 · 18 comments
Labels
question Further information is requested

Comments

@CzzzzzzJ
Copy link

$ python test/twoagent.py
Traceback (most recent call last):
File "D:\workspace\luan\autogen\test\twoagent.py", line 1, in
from autogen import AssistantAgent, UserProxyAgent, config_list_from_json
ImportError: cannot import name 'AssistantAgent' from 'autogen' (C:\Users\Administrator\AppData\Local\Programs\Python\Python311\Lib\site-packages\autogen_init_.py)

Yesterday it worked fine, but today it runs and shows this error.

@afourney afourney added the question Further information is requested label Nov 17, 2023
@afourney
Copy link
Member

afourney commented Nov 17, 2023

This can happen if there is a file named autogen.py in your current folder. Can you confirm that you do not have any files or folders named autogen in the directory where you are working?

@zepef
Copy link

zepef commented Nov 17, 2023

Same thing Bro:

teachable_agent = atg.TeachableAgent(
name="teachableagent",
llm_config=llm_config,
teach_config={
"reset_db": False, # Use True to force-reset the memo DB, and False to use an existing DB.
"path_to_db_dir": "./tmp/interactive/teachable_agent_db" # Can be any path.
}
)

user = atg.UserProxyAgent("user", human_input_mode="ALWAYS")

GIVES >>>

Traceback (most recent call last):
File "f:\Trials\autoloc\app.py", line 17, in
teachable_agent = atg.TeachableAgent(
AttributeError: module 'autogen' has no attribute 'TeachableAgent'

@zepef
Copy link

zepef commented Nov 17, 2023

Maybe a python version issue?

@zepef
Copy link

zepef commented Nov 19, 2023

Uninstalling and reinstalling worked for me. I noticed I did not have to specifically mention [teachable] to have it installed.

@rickyloynd-microsoft
Copy link
Contributor

Looks like this is resolved.

@yhygta
Copy link

yhygta commented Dec 18, 2023

Maybe you have installed
"pip install autogen"
NOT
"pip install pyautogen"

@hyp9h
Copy link

hyp9h commented Dec 25, 2023

I used 'pip install autogen' by mistake,uninstalling autogen and autopep8 worked for me

@yaJannik
Copy link

Was running into the same problem. Maybe highlight this in the installation documentation.

@afourney
Copy link
Member

I believe I approved a documentation PR yesterday that adds this to the FAQ. Hopefully merged soon (if not already)

@teachable-david
Copy link

I uninstalled autogen and autopep8, and upgraded pyautogen, and the error became:

ImportError: cannot import name 'UserProxyAgent' from 'autogen' (unknown location)

@teachable-david
Copy link

copied the basic autogen script from this video by @tylerprogramming and am getting this error:

AttributeError: module 'autogen' has no attribute 'config_list_from_json'

@tylerprogramming
Copy link

tylerprogramming commented Feb 29, 2024

copied the basic autogen script from this video by @tylerprogramming and am getting this error:

AttributeError: module 'autogen' has no attribute 'config_list_from_json'

Hey @teachable-david, I can try to help you! Thanks for watching the video, but I guess the first thing (if you haven't already) is to try to pip uninstall autogen, and then pip install pyautogen

I see you tried above from reading more comments, but since it can't find the library from what it seems, try the below two ways it may work:

If you have already tried that, I don't know exactly why this has worked for me, but remove the import, and then re-type it. Sometimes it then was able to find the library for use.

Also try a brand new project and pip install pyautogen, and see if the IDE recognizes autogen.config_list_from_json

Let me know and I can try to help more

@teachable-david
Copy link

Thanks for the reply @tylerprogramming! I followed the pip installation suggestions. I also installed Visual Studio since I'd been working in VS Code and I learned that doesn't allow project creation. I've started a new project in Visual Studio and copied the code into it from your video. I also followed the instructions in the terminal to add a folder location to my path/environment variables. But when I run the autogen script, I still see the error, "no module named autogen."

In this thread it's also suggested that pyautogen is the issue, but I have upgraded it and uninstalled autogen. I have had success with AutoGen in the past without using a Python environment, so I don't expect that to be the issue. However, since I'm currently stumped, I will probably create a venv and start the project again in it. I'll try anything else that you think might help. Thanks again!

@Aqq-Ubemm
Copy link

Maybe you have installed "pip install autogen" NOT "pip install pyautogen"
i try this kind of method, its solved

@WUHAN563
Copy link

WUHAN563 commented Jun 4, 2024

Thanks for the reply @tylerprogramming! I followed the pip installation suggestions. I also installed Visual Studio since I'd been working in VS Code and I learned that doesn't allow project creation. I've started a new project in Visual Studio and copied the code into it from your video. I also followed the instructions in the terminal to add a folder location to my path/environment variables. But when I run the autogen script, I still see the error, "no module named autogen."

In this thread it's also suggested that pyautogen is the issue, but I have upgraded it and uninstalled autogen. I have had success with AutoGen in the past without using a Python environment, so I don't expect that to be the issue. However, since I'm currently stumped, I will probably create a venv and start the project again in it. I'll try anything else that you think might help. Thanks again!

Before creating a new environment, please clean cache for both conda and pip.
conda clean --all
pip cache purge

@nise
Copy link

nise commented Jun 6, 2024

Tried this in notebook:

!pip cache purge
!pip uninstall pyautogen -y
!pip uninstall autogen -y
!pip install pyautogen

from autogen import ConversableAgent, UserProxyAgent

def main():
    assistant = ConversableAgent("agent", llm_config={"config_list": config_list})
    user_proxy = UserProxyAgent("user", code_execution_config=False)
    assistant.initiate_chat(user_proxy, message="How can I help you today?")
if __name__ == "__main__":
    main()

It still results in: ImportError: cannot import name 'ConversableAgent' from 'autogen' (unknown location)

@gops-sukumar
Copy link

By doing all the above, I am able to import other agents like UserProxyAgent, but not TeachableAgent. What could be the issue?

@tylerprogramming
Copy link

@gops-sukumar Hey, so just checking and I don't see the TeachableAgent as part of the autogen code. That's why it cannot import it. It's been a while since I've used it, but it seems they either removed it completely.

I think they re-vamped it. Looking through, they have a 'teachability' in the contributions section. What this does, is create a teachable agent in the class, but REALLY it's just a 'conversableagent'. They modify how it behaves.

Example:

"# Making OpenAI Assistants Teachable\n",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests