Certbot installations in /usr/local
are almost always was caused by installing Certbot globally through pip
which is not supported by Certbot. Installing any Python packages in this way can cause problems like this because pip
and your OS package manager do not work well together. Using both package managers to install Python packages can result in conflicting dependencies or broken installations because the two package managers improperly modify packages installed by the other.
To fix this, I would remove all packages installed through pip
by running the command below.
WARNING: You should only run this command on Debian based systems such as Ubuntu because on some other OSes the command will improperly remove Python packages installed by your OS package manager.
sudo pip3 uninstall -y -r <(pip3 freeze)