-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Dataprotection ModuleNotFoundError 'azure.mgmt.resourcegraph' #4562
Comments
To my surprise hotfix via pip and pip3 With |
route to CXP team |
@HansZimmer5000 Thanks for reaching out to us and proving the current update. Please let us know if you are still facing any issues while running the |
@HansZimmer5000 I wanted to do quick follow-up to check if you had a chance to look at my above comment. Please let me know if you are still facing the same issue. Awaiting your reply. |
Good day @navba-MSFT !
If you mean the pip3 install I mentioned above, that does not change the issue. |
Let me clarify 2 things:
I am also able to reproduce this issue on Windows:
|
CauseEven though Azure/azure-cli#13163 added the support to load def add_extension_to_path(extension_name, ext_dir=None):
ext_dir = ext_dir or get_extension(extension_name).path
sys.path.append(ext_dir)
# If this path update should have made a new "azure" module available,
# extend the existing module with its path. This allows extensions to
# include (or depend on) Azure SDK modules that are not yet part of
# the CLI. This applies to both the "azure" and "azure.mgmt" namespaces,
# but ensures that modules installed by the CLI take priority.
azure_dir = os.path.join(ext_dir, "azure")
if os.path.isdir(azure_dir):
import azure
azure.__path__.append(azure_dir)
azure_mgmt_dir = os.path.join(azure_dir, "mgmt")
if os.path.isdir(azure_mgmt_dir):
try:
# Should have been imported already, so this will be quick
import azure.mgmt
except ImportError:
pass
else:
azure.mgmt.__path__.append(azure_mgmt_dir) it is not used in core's extension loading process (but in other modules like network): ext_dir = ext.path or get_extension_path(ext_name)
sys.path.append(ext_dir) We can show what import azure
print(azure.__path__)
Because SolutionThe common practice is to put SDKs in a To my surprise, this extension was added by #3459 (Jun 3, 2021) but this bug is never discovered. |
This problem also happens in a virtual env, but not Azure CLI installed with MSI or DEB: I tested with a sample script: import sys
import azure
print(azure, azure.__path__)
sys.path.append(r'C:\Users\username\.azure\cliextensions\dataprotection')
import azure
print(azure, azure.__path__)
import azure.mgmt
print(azure.mgmt, azure.mgmt.__path__)
import azure.mgmt.resourcegraph
print(azure.mgmt.resourcegraph, azure.mgmt.resourcegraph.__path__) System python:
Virtual env python:
In a virtual env which installs Azure CLI from source code, under __path__ = __import__("pkgutil").extend_path(__path__, __name__) These files make |
@HansZimmer5000 Apologies for the late reply. Could you please refer this comment and follow the workaround suggested there? Please let me know if you face any issues. Awaiting your reply. |
@HansZimmer5000 Could you please let me know if you have any follow-up question on this ? |
@HansZimmer5000 Please let me know if you had a chance to look at the above comments. Awaiting your reply. |
@sambitratha Could you please vendor |
@HansZimmer5000 We will now proceed with closure of this github issue. Once you have an update and need any further assistance on this issue, please feel free to reopen this thread. We would be happy to help. |
Good day @jiasli ! Please excuse my late response. Thank you very much for the detailed debugging. fyi: In |
The |
I understand that of course I could just install this missing module via pip3 as a hotfix. But, I also think this is not how this extension should behave in the first place.
Is there maybe something missing during installation of the extension? Didn't experience any ModuleNotFoundErrors before.
Find below the 'az feedback --verbose' output with the list of my installed extensions, I manually noted which of them is a preview version.
Extension name (the extension in question)
dataprotection
Description of issue (in as much detail as possible)
This is autogenerated. Please review and update as needed.
Describe the bug
az feedback --verbose
Command Name
az dataprotection backup-instance
Errors:
To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
az extension add -n dataprotection
(explicit). Both ways led to the same outcome.az dataprotection backup-instance -h
or anyaz dataprotection backup-instance
subcommand.Expected Behavior
Shows help output.
Environment Summary
Additional Context
The text was updated successfully, but these errors were encountered: