Score:4

Problem with Certbot after Ubuntu upgrade to 22.04

mv flag

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?

Score:3
cn flag

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 :)

Organic Marble avatar
us flag
Thanks, I learned something from this. I checked in my server and `certbot` is indeed in /usr/bin, so that matches.
Kaziu avatar
mv flag
Big Thanks! It works, you safe me :)
pa4080 avatar
cn flag
I'm happy to help! :)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.