Search code examples
pythonpython-3.xlinuxcertbotpython-3.10

Python Certbot module 'collections' has no attribute 'Mapping'


when I try to run certbot in my console on my Linux Ubuntu Server 20.04.3 LTS, I get following error:

Traceback (most recent call last):
  File "/usr/bin/certbot", line 11, in <module>
    load_entry_point('certbot==0.40.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 490, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2854, in load_entry_point
    return ep.load()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2445, in load
    return self.resolve()
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2451, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 18, in <module>
    from certbot import cert_manager
  File "/usr/lib/python3/dist-packages/certbot/cert_manager.py", line 15, in <module>
    from certbot import ocsp
  File "/usr/lib/python3/dist-packages/certbot/ocsp.py", line 25, in <module>
    from certbot.storage import RenewableCert # pylint: disable=unused-import
  File "/usr/lib/python3/dist-packages/certbot/storage.py", line 15, in <module>
    from certbot import cli
  File "/usr/lib/python3/dist-packages/certbot/cli.py", line 33, in <module>
    from certbot.plugins import disco as plugins_disco
  File "/usr/lib/python3/dist-packages/certbot/plugins/disco.py", line 183, in <module>
    class PluginsRegistry(collections.Mapping):
AttributeError: module 'collections' has no attribute 'Mapping'

I have already searched for a solution, but have not found one. Even posts that have the same error could not solve the problem for me. Strangely enough, it worked about two months ago.

I'm running Python 3.10.


Solution

  • In my case, I edited the file /usr/bin/certbot and changed #!/usr/bin/python3 to: #!/usr/bin/python3.8 because Certbot does not support Python 3.10 yet