'AWS CLI with Python 3.9.0a1 error `from collections import MutableMapping`
I have installed AWS CLI using pip on my Python 3.9.0a1
alpine docker image. Install went fine. When I run aws
command, getting below error.
aws
Traceback (most recent call last):
File "/usr/local/bin/aws", line 27, in <module>
sys.exit(main())
File "/usr/local/bin/aws", line 23, in main
return awscli.clidriver.main()
File "/usr/local/lib/python3.9/site-packages/awscli/clidriver.py", line 68, in main
driver = create_clidriver()
File "/usr/local/lib/python3.9/site-packages/awscli/clidriver.py", line 77, in create_clidriver
load_plugins(session.full_config.get('plugins', {}),
File "/usr/local/lib/python3.9/site-packages/awscli/plugin.py", line 44, in load_plugins
modules = _import_plugins(plugin_mapping)
File "/usr/local/lib/python3.9/site-packages/awscli/plugin.py", line 61, in _import_plugins
module = __import__(path, fromlist=[module])
File "/usr/local/lib/python3.9/site-packages/awscli/handlers.py", line 42, in <module>
from awscli.customizations.history import register_history_mode
File "/usr/local/lib/python3.9/site-packages/awscli/customizations/history/__init__.py", line 24, in <module>
from awscli.customizations.history.db import DatabaseConnection
File "/usr/local/lib/python3.9/site-packages/awscli/customizations/history/db.py", line 19, in <module>
from collections import MutableMapping
ImportError: cannot import name 'MutableMapping' from 'collections' (/usr/local/lib/python3.9/collections/__init__.py)
python --version
Python 3.9.0a1
Do I need to install any other module to fix this error message?
Thanks
Solution 1:[1]
collections.MutableMapping
has been deprecated since Python 3.3, and was officially removed since Python 3.9.
Excerpt from the documentation:
Deprecated since version 3.3, will be removed in version 3.9: Moved Collections Abstract Base Classes to the
collections.abc
module.
You can either wait for a Python 3.9-compatible version of awscli
to be released, or patch the aws
script (under your /usr/local/bin
) yourself like this for the time being:
...
import collections
from collections import abc
collections.MutableMapping = abc.MutableMapping
import awscli.clidriver
Solution 2:[2]
I also encountered this error and was not able to get the import work arounds to work.
I did run my work on Google Colab https://colab.research.google.com/ which works a bit like Jupyter Notebook and the code ran fine without having the the MutableMapping issue. I realize that this is not ideal for every user case, but it is a workaround.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Christopher |