使用Azure-Cli创建新的容器

时间:2018-09-19 15:27:46

标签: python azure azure-cli

我用Homebrew brew update && brew install azure-cli

安装了azure-cli

所有azure命令都没有成功。无论命令如何,都会出现以下错误。

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'

我试图做pip install setuptools 这给了我

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

Azure是否尝试使用缺少安装工具的其他版本的python?我使用的是错误版本的python吗?

我真的不知道从这里去哪里。

python --version说我正在使用Python 3.7.0

1 个答案:

答案 0 :(得分:0)

您所说的azure命令都没有成功。因此,我建议您重新安装Azure CLI,可以按照Install Azure CLI 2.0进行操作。

另外,通过python安装Azure CLI:

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

有关更多详细信息,请遵循此link

关于为存储创建一个容器。您可以通过以下CLI命令执行此操作:

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

容器名称在这里有限制:

  

一个容器组织了一组Blob,类似于文件中的文件夹   系统。所有斑点都位于容器内。一个存储帐户可以   包含无限数量的容器,并且一个容器可以存储   无限数量的斑点。 请注意,容器名称必须为   小写。

所以您应该注意它。希望对您有帮助。