question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot import name 'Iterable' from 'collections'

See original GitHub issue

Describe the bug

Command Name az aks get-credentials

Errors:

The command failed with an unexpected error. Here is the traceback:
cannot import name 'Iterable' from 'collections' (/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)
Traceback (most recent call last):
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/knack/cli.py", line 231, in invoke
    cmd_result = self.invocation.execute(args)
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 556, in execute
    self.commands_loader.load_arguments(command)
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/__init__.py", line 517, in load_arguments
    self.command_table[command].load_arguments()  # this loads the arguments via reflection
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/__init__.py", line 313, in load_arguments
    super(AzCliCommand, self).load_arguments()
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/knack/commands.py", line 104, in load_arguments
    cmd_args = self.arguments_loader()
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 125, in arguments_loader
    op = self.get_op_handler(self.op_path)
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 59, in get_op_handler
    handler = import_module(mod_to_import)
  File "/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/fed/.azure/cliextensions/aks-preview/azext_aks_preview/custom.py", line 41, in <module>
    from tabulate import tabulate  # pylint: disable=import-error
  File "/usr/local/Cellar/azure-cli/2.30.0_1/libexec/lib/python3.10/site-packages/tabulate.py", line 16, in <module>
    from collections import Iterable
ImportError: cannot import name 'Iterable' from 'collections' (/usr/local/Cellar/python@3.10/3.10.0_2/Frameworks/Python.framework/Versions/3.10/lib/python3.10/collections/__init__.py)

To Reproduce:

  • az aks get-credentials --resource-group {} --name {} --subscription {} --admin

Expected Behavior

Environment Summary

macOS-11.6-x86_64-i386-64bit, Darwin 20.6.0
Python 3.10.0
Installer: HOMEBREW

azure-cli 2.30.0

Extensions:
front-door 1.0.9
aks-preview 0.4.65

Additional Context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
PratyushBasucommented, Jan 11, 2022

The issue is with the Python version (>3.9)… Python realigned the modules.

  1. either use Python v3.9 or prior ones OR
  2. The base package needs to be modified (from where this import error is generating)
try:
    # Python <= 3.9
    from collections import Iterable
except ImportError:
    # Python > 3.9
    from collections.abc import Iterable
1reaction
Andy-Pham-72commented, Dec 3, 2021

Thanks @miwithro, I have tried this already.

I have tried just simply uninstalling and re-installing as well as uninstalling, running brew cleanup -s and even removing the brew cache directory rm -rf $(brew --cache) before re-installing again still yields the same results

Thank you so much for your solution! I was able to run the command!

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot import name 'Iterable' from 'collections' in Python
You can use Iterable from collections.abc instead, or use Python 3.9 if the problem is in a dependency that can't be updated.
Read more >
ImportError: cannot import name Iterable from 'collections'
Import the Iterable class from collections.abc , as a change was made in Python 3.10. · Update the versions of any modules that...
Read more >
ImportError cannot import name Iterabler from collections ...
The Iterable abstract class was removed from collections in Python 3.10. ... ImportError: cannot import name 'Iterable' from 'collections'.
Read more >
1926080 – packit fails to build with Python 3.10: ImportError
Bug 1926080 - packit fails to build with Python 3.10: ImportError: cannot import name 'Iterable' from 'collections'.
Read more >
【Python】pyecharts库报错cannot import name 'Iterable' ...
解决办法:到安装pyecharts库的目录下,进入pyecharts文件,再打开render,继续打开engine.py文件,在其中找到下面的代码:from collections import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found