Azure / azure-cli-extensions

Public Repository for Extensions of Azure CLI.
https://docs.microsoft.com/en-us/cli/azure
MIT License
384 stars 1.25k forks source link

ModuleNotFoundError: No module named 'azure.communication' #6803

Open rfc821 opened 1 year ago

rfc821 commented 1 year ago

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

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

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

cli.knack.cli: __init__ debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x102e4a170>, <function OutputProducer.on_global_arguments at 0x102eded40>, <function CLIQuery.on_global_arguments at 0x102f481f0>]
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 [<function AzCliLogging.init_command_file_logging at 0x1039f5c60>]
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 [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x103a125f0>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x103b10040>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x103b10160>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x102ededd0>, <function CLIQuery.handle_query_parameter at 0x102f48280>, <function register_ids_argument.<locals>.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 [<function AzCliLogging.deinit_cmd_metadata_logging at 0x1039f5ea0>]
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:

yonzhan commented 1 year ago

Thank you for opening this issue, we will look into it.

navba-MSFT commented 1 year ago

@rfc821 Thanks for reaching out to us and reporting this issue. We are looking into this issue and we will provide an update.

Plan 1: Please run the pip list command on your box and check if azure.communication package is present.

Plan 2: Please run the below command in order:

pip3 uninstall azure-communication-email

pip3 install azure-communication-email==1.0.0

pip3 install azure-communication-administration

Plan 3: Could you try the steps mentioned here in the official docs and/or try reinstalling Azure CLI?

Here are the same for reference

brew update && brew install python@3.10 && brew upgrade python@3.10
brew link --overwrite python@3.10

Please let me know if you still see the same issue after following the above plans. Awaiting your reply.

rfc821 commented 1 year ago

Plan 1: Do not have the pip command. But used pip3 list instead:

Package                            Version
---------------------------------- ---------
altgraph                           0.17.2
azure-common                       1.1.28
azure-communication-administration 1.0.0b4
azure-communication-email          1.0.0
azure-communication-identity       1.3.1
azure-core                         1.29.4
azure-mgmt-core                    1.4.0
certifi                            2023.7.22
charset-normalizer                 3.2.0
future                             0.18.2
idna                               3.4
isodate                            0.6.1
macholib                           1.15.2
msrest                             0.7.1
oauthlib                           3.2.2
pip                                23.2.1
requests                           2.31.0
requests-oauthlib                  1.3.1
setuptools                         58.0.4
six                                1.15.0
typing_extensions                  4.8.0
urllib3                            2.0.5
wheel                              0.37.0

Plan 2: done

Plan 3: done

Result: I did run the command email send again and it resulted in the same error. The issue still persists:

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'
To check existing issues, please visit: https://github.com/Azure/azure-cli/issues
smereczynski commented 1 year ago

In my opinion pip3 list is not listing site-packages from the directory where azure-cli is storing it's modules. There is no azure-communication-sms or azure-communication-email in this directory. There is also no azure-communication-sms or azure-communication-email in pip list when listing in python binary installed by brew and used by azure-cli. Something is probably wrong with installing this extension when azure-cli is installed by brew.

navba-MSFT commented 1 year ago

Service team has been added to look into this further.

bounaux commented 11 months ago

I was able to repro this issue today, any update pls?

tylermneher commented 5 months ago

Still encountering this issue, is there any update to report?

jornbeyers commented 5 months ago

I am also experiencing this on Mac Sonoma 14.5

jchoi926 commented 5 months ago

We're approaching a year on this issue - is there an update?

Additional context: I have the azure cli installed with brew and added the container apps extension with the az extension add --name command. The container apps extension works as expected.