Azure / Azure/azure-cli-extensions

ModuleNotFoundError: No module named 'azure.communication'

Open
#6,803 9 comments 0 reactions 0 assignees View on GitHub
Auto-Assign Communication customer-reported needs-team-attention question Service Attention
Dominant language
Python
Stars
454
Forks
1.7k
Avg merge
2d 19h
Merged PRs (30d)
64

Description

### Describe the bug

Tried sending an email following https://learn.microsoft.com/en-us/cli/azure/communication/email?view=azure-cli-latest
I am using a macOS Ventura 13.6 with Apple Silicon

### Related command

```bash
az communication email send --connection-string "[filled]" --sender "[filled]" --to "[filled]" --subject "Welcome to Azure Communication Services Email" --text "This email message is sent from Azure Communication Services Email using Azure CLI."
```

### Errors

```bash
The command failed with an unexpected error. Here is the traceback:
No module named 'azure.communication'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
File "/Users/benni/.azure/cliextensions/communication/azext_communication/manual/_client_factory.py", line 85, in cf_communication_email
from azure.communication.email import EmailClient
ModuleNotFoundError: No module named 'azure.communication'
```

### Issue script & Debug output

```bash
cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [, , ]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'communication': ['azext_communication']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: Total (0) 0.000 0 0
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: communication 0.130 18 51 /Users/myusername/.azure/cliextensions/communication
cli.azure.cli.core: Total (1) 0.130 18 51
cli.azure.cli.core: Loaded 18 groups, 51 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : communication email send
cli.azure.cli.core: Command table: communication email send
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate []
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to '/Users/myusername/.azure/commands/2023-09-25.13-37-05.communication_email_send.23738.log'.
az_command_data_logger: command args: communication email send --connection-string {} --sender {} --to {} --subject {} --text {} --debug
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [.add_subscription_parameter at 0x103a125f0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [.add_ids_arguments at 0x103b10040>, .add_cache_arguments at 0x103b10160>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [, , .parse_ids_arguments at 0x103b100d0>]
az_command_data_logger: extension name: communication
az_command_data_logger: extension version: 1.7.2b1
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
File "/Users/myusername/.azure/cliextensions/communication/azext_communication/manual/_client_factory.py", line 85, in cf_communication_email
from azure.communication.email import EmailClient
ModuleNotFoundError: No module named 'azure.communication'

cli.azure.cli.core.azclierror: The command failed with an unexpected error. Here is the traceback:
az_command_data_logger: The command failed with an unexpected error. Here is the traceback:
cli.azure.cli.core.azclierror: No module named 'azure.communication'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
File "/Users/myusername/.azure/cliextensions/communication/azext_communication/manual/_client_factory.py", line 85, in cf_communication_email
from azure.communication.email import EmailClient
ModuleNotFoundError: No module named 'azure.communication'
az_command_data_logger: No module named 'azure.communication'
Traceback (most recent call last):
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 663, in execute
raise ex
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 333, in __call__
return self.handler(*args, **kwargs)
File "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 112, in handler
client = self.client_factory(self.cli_ctx, command_args) if self.client_factory else None
File "/Users/myusername/.azure/cliextensions/communication/azext_communication/manual/_client_factory.py", line 85, in cf_communication_email
from azure.communication.email import EmailClient
ModuleNotFoundError: No module named 'azure.communication'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
cli.knack.cli: Event: Cli.PostExecute []
az_command_data_logger: exit code: 1
cli.__main__: Command ran in 0.372 seconds (init: 0.154, invoke: 0.218)
telemetry.main: Begin splitting cli events and extra events, total events: 1
telemetry.client: Accumulated 0 events. Flush the clients.
telemetry.main: Finish splitting cli events and extra events, cli events: 1
telemetry.save: Save telemetry record of length 7505 in cache
telemetry.main: Begin creating telemetry upload process.
telemetry.process: Creating upload process: "/opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/bin/python /opt/homebrew/Cellar/azure-cli/2.52.0_1/libexec/lib/python3.10/site-packages/azure/cli/telemetry/__init__.py /Users/myusername/.azure"
telemetry.process: Return from creating process
telemetry.main: Finish creating telemetry upload process.
```

### Expected behavior

Should find the installed communication extension and try to send email.

### Environment Summary

azure-cli 2.52.0

core 2.52.0
telemetry 1.1.0

Extensions:
account 0.2.5
communication 1.7.2b1

Dependencies:
msal 1.24.0b1
azure-mgmt-resource 23.1.0b2

### Additional context

Looks like this is a common issue also with oder versions of the communication extension on Apple macOS. There were already some issues, but they were closed due to no reaction:

- [6333](https://github.com/Azure/azure-cli-extensions/issues/6333)
- [5570](https://github.com/Azure/azure-cli-extensions/issues/5570)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.