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

No module named 'azure' -- installation instruction of magentic one needs to be updated #4899

Closed
auserwn opened this issue Jan 6, 2025 · 7 comments
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers proj-agentchat
Milestone

Comments

@auserwn
Copy link

auserwn commented Jan 6, 2025

Here is my code:

import os
os.environ["api_key"]="sk-xxxxx"
os.environ["base_url"] = "xxxx"

import asyncio
from autogen_ext.models.openai import OpenAIChatCompletionClient
from autogen_ext.teams.magentic_one import MagenticOne
from autogen_agentchat.ui import Console

async def example_usage_hil():
client = OpenAIChatCompletionClient(model="gpt-4o")
# to enable human-in-the-loop mode, set hil_mode=True
m1 = MagenticOne(client=client, hil_mode=True)
task = "Write a Python script to fetch data from an API."
result = await Console(m1.run_stream(task=task))
print(result)

if name == "main":
asyncio.run(example_usage_hil())

The error is as follows:

Traceback (most recent call last):
File "xx\newCoder\autogen_related\magentic_one\magent_test_1.py", line 6, in
from autogen_ext.models.openai import OpenAIChatCompletionClient
File "D:\python-3.11.6\Lib\site-packages\autogen_ext\models\openai_init_.py", line 1, in
from ._azure_token_provider import AzureTokenProvider
File "D:\python-3.11.6\Lib\site-packages\autogen_ext\models\openai_azure_token_provider.py", line 4, in
from azure.core.credentials import TokenProvider
ModuleNotFoundError: No module named 'azure'

Why is Azure needed here? How should I modify it?

@PratyushNag
Copy link
Contributor

I was facing the same issue yesterday, Installing azure separately solved it for me

pip install azure-storage-blob azure-identity

I installed it using this command

@rajib76
Copy link

rajib76 commented Jan 6, 2025 via email

@ekzhu
Copy link
Collaborator

ekzhu commented Jan 6, 2025

Thanks for the issue.

This doc should be updated to add openai extra to the installation instructions.

pip install autogen-agentchat==0.4.0.dev13 autogen-ext[magentic-one]==0.4.0.dev13

A really quick fix if anyone wants to contribute.

@ekzhu ekzhu added proj-agentchat documentation Improvements or additions to documentation good first issue Good for newcomers and removed needs-triage labels Jan 6, 2025
@ekzhu ekzhu added this to the 0.4.0 milestone Jan 6, 2025
@ekzhu ekzhu changed the title No module named 'azure' No module named 'azure' -- installation instruction of magentic one needs to be updated Jan 6, 2025
@Zochory
Copy link

Zochory commented Jan 6, 2025

It's either this, or that azure is used maybe by default also for the Session pool 🤷

@auserwn
Copy link
Author

auserwn commented Jan 6, 2025

Thank you, it works now. I really appreciate it!

@JMLX42
Copy link
Contributor

JMLX42 commented Jan 6, 2025

The problem still exists despite #4903

pip install azure-identity does fix the problem though.

@jackgerrits
Copy link
Member

jackgerrits commented Jan 6, 2025

When I implemented component config support I didn't realize it would make azure libs required when importing the openai client. #4757 so this is my mistake

I think the right thing to do here is split out the azure client into from autogen_ext.models.azure_openai import AzureOpenAIChatCompletionClient to make the dependencies separate and intention clear. It is a breaking change for users of the azure client unfortunately but I think it is best we do this before we cut the full 0.4.0 release.

I really don't want to force people who just want to use openai to have to install azure libs too... That's not right

@ekzhu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation good first issue Good for newcomers proj-agentchat
Projects
None yet
Development

No branches or pull requests

7 participants