4

I have a problem with Certbot after upgrading to Ubuntu 22.04. I tried to reinstall Certbot without success. Then I tried to install Certbot with snap, and I have the same problem:

 certbot --version
Traceback (most recent call last):
  File "/usr/local/bin/certbot", line 33, in <module>
    sys.exit(load_entry_point('certbot', 'console_scripts', 'certbot')())
  File "/usr/local/bin/certbot", line 22, in importlib_load_entry_point
    for entry_point in distribution(dist_name).entry_points
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 957, in distribution
    return Distribution.from_name(distribution_name)
  File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 548, in from_name
    raise PackageNotFoundError(name)
importlib.metadata.PackageNotFoundError: No package metadata was found for certbot

I cant renew certs for my domains. How can I resolve this?

pa4080
  • 30,621
Kaziu
  • 43

1 Answers1

4

Within the error message provided in the question, I noticed the problematic Certbot's executable is /usr/local/bin/certbot.

Usually the executable files located in /usr/local/bin are a kind of custom installations and they take precedence over these installed by the package managers, because of the default structure of the $PATH variable - to check it run:

echo $PATH

On the other hand, packages installed with apt could be found in the other directories like /usr/bin or /usr/sbin, or /bin, or /snap/bin for the snap packages, etc.

So different versions of a command (with the same name) could exist in different directories which belong to your $PATH. To find which one takes precedence over the others you can use the command:

which certbot

To find the locations of all executable files named certbot within the directories in the $PATH use the command:

which -a certbot

In a case the above command outputs more than one line - for example:

/usr/local/bin/certbot
/usr/bin/certbot
/bin/certbot

You can try to renew your certificates by the second (or the third) command by calling it with its full path - i.e. /usr/bin/certbot.

If this works,you can safely remove the obsolete executable /usr/local/bin/certbot which probably was installed a long time ago while you've followed some guide which you can't remember right now :)

guntbert
  • 13,475
pa4080
  • 30,621