0

I installed azure-cli with Homebrew brew update && brew install azure-cli

None of the azure commands have been successful. No matter the command I get the the following error.

az storage container create --name testContainer
No module named 'pkg_resources'
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/knack/cli.py", line 197, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 262, in execute
    self.commands_loader.load_arguments(command)
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/azure/cli/core/__init__.py", line 253, in load_arguments
    self.command_table[command].load_arguments()  # this loads the arguments via reflection
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/azure/cli/core/commands/__init__.py", line 141, in load_arguments
    super(AzCliCommand, self).load_arguments()
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/knack/commands.py", line 76, in load_arguments
    cmd_args = self.arguments_loader()
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/azure/cli/core/__init__.py", line 440, in default_arguments_loader
    op = handler or self.get_op_handler(operation)
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/azure/cli/core/__init__.py", line 485, in get_op_handler
    op = import_module(mod_to_import)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/Cellar/azure-cli/2.0.45/libexec/lib/python3.7/site-packages/azure/multiapi/__init__.py", line 1, in <module>
    __import__('pkg_resources').declare_namespace(__name__)
ModuleNotFoundError: No module named 'pkg_resources'

I've attempted to do pip install setuptools which gives me:

Requirement already satisfied: setuptools in ./Library/Python/2.7/lib/python/site-packages (40.4.1)

Is azure trying to use a different version of python that's missing setup tools? Am I using the wrong version of python?

I don't really know where to go from here.

python --version says i'm using Python 3.7.0

Reed
  • 177
  • 3
  • 10
  • You should create an issue here and CLI team will help you to figure out what is happening: https://github.com/Azure/azure-cli/issues. Also, you don't confirm how you installed the CLI is the first place. Pip? Howebrew? Something else? Please update your post with installation details. – Laurent Mazuel Sep 19 '18 at 15:41
  • @LaurentMazuel, updated. I'll post in their issues as well. – Reed Sep 19 '18 at 15:47
  • A similar error - https://stackoverflow.com/questions/7446187/no-module-named-pkg-resources – Shiva Sep 19 '18 at 16:19
  • Your message show the CLI is in 3.7, and you pip try is in 2.7 (look at the path). Try "python -m pip install setuptools" – Laurent Mazuel Sep 19 '18 at 22:48
  • What the steps do you follow? This [link](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest)? – Charles Xu Sep 20 '18 at 01:13
  • I ended up running a Brew Uninstall of Azure-Cli and then doing a pip install of the same package and it worked ¯\_(ツ)_/¯ – Reed Sep 21 '18 at 00:11
  • If the answer is helpful you can accept it. – Charles Xu Sep 27 '18 at 06:18

1 Answers1

0

As you say none of the azure commands have been successful. So I suggest you reinstall the Azure CLI, you can follow Install Azure CLI 2.0.

Additional, install Azure CLI through python:

pip install --pre --user azure-nspkg 
pip install --pre --user azure-multiapi-storage
pip install azure-cli

For more details, follow this link.

About create a container for the storage. You can do that with the CLI command here:

az storage container create --name containerName --account-name accountName --account-key accountKey

And the container name has the limitation here:

A container organizes a set of blobs, similar to a folder in a file system. All blobs reside within a container. A storage account can contain an unlimited number of containers, and a container can store an unlimited number of blobs. Note that the container name must be lowercase.

So you should pay attention to it. Hope this will help you.

Charles Xu
  • 24,004
  • 1
  • 12
  • 27
  • My solution was to reinstall the CLI using pip instead of brew. If you include `pip install azure-cli` in your answer I'll accept it. – Reed Oct 31 '18 at 19:15