Resolved: unable to install latest certbot on Linux


Below is my Linux version
root@DKERP:~# uname -a
Linux DKERP 5.4.0-96-generic #109-Ubuntu SMP Wed Jan 12 16:49:16 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
I tried the below commands as root user inorder to install the latest certbot.
      246  sudo apt-get update
      247  sudo apt-get install --only-upgrade certbot
      249  wget
      250  sudo apt-get update -y
      251  sudo apt-get install software-properties-common
      252  sudo add-apt-repository universe
      253  sudo add-apt-repository ppa:certbot/certbot
      254  sudo apt-get update -y
      255  sudo apt-get install certbot python-certbot-nginx
      256  sudo apt-get install certbot python-certbot-apache
      258  sudo apt update
      259  sudo apt install --only-upgrade certbot
However, I get the below error when I first the certbot command
root@DKERP:~# certbot
Traceback (most recent call last):
  File "/usr/bin/certbot", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python3/dist-packages/pkg_resources/", line 3254, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3/dist-packages/pkg_resources/", line 3237, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/", line 3266, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3/dist-packages/pkg_resources/", line 584, in _build_master
  File "/usr/lib/python3/dist-packages/pkg_resources/", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3/dist-packages/pkg_resources/", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'certbot==0.40.0' distribution was not found and is required by the application
Can you please suggest?


Did you try to install it using Snap? Maybe it can solve the problem because it seems to have a conflict with python 3 packages:
 sudo snap install certbot --classic

If you have better answer, please add a comment about this, thank you!