Hello, I’m trying to upgrade the certificates on a vps and I receive the following error:
zzzzzz@xxxxxxxxx:~$ sudo certbot --apache renew
Traceback (most recent call last):
File "/usr/bin/certbot", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.7/dist-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
I’ve tryed sudo apt remove certbot --purge followed by sudo apt install certbot without changes.
Here is the full output of sudo python -v /usr/bin/certbot --apache renew
It seems like this might be a result of different installations for your Python. (e.g. installed from different source).
Can you try the answer listed below and upgrade you pip? sudo python -m ensurepip --upgrade
sudo python -m ensurepip --upgrade
/usr/bin/python: No module named ensurepip
pip -V
pip 20.0.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)
python -m pip -V
pip 20.0.2 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)
UPDATE
I've created a venv and executed sudo python -m ensurepip --upgrade into it, result:
ensurepip is disabled in Debian/Ubuntu for the system python.
Python modules for the system python are usually handled by dpkg and apt-get.
apt-get install python-<module name>
Install the python-pip package to use pip itself. Using pip together
with the system python might have unexpected results for any system installed
module, so use it on your own risk, or make sure to only use it in virtual
environments.
(inside the venv)
pip install --upgrade pip
Successfully installed pip-20.0.2
pip install --upgrade certbot
Requirement already up-to-date: certbot in ./certbot_env/lib/python3.7/site-packages (1.3.0)
pip -V
pip 20.0.2 (python 3.7)
certbot --version
certbot 1.3.0
sudo certbot --apache renew
Traceback (most recent call last):
File "/usr/bin/certbot", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.7/dist-packages/pkg_resources.py", line 1479, in <module>
register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
#!/bin/bash
if [ "$1" != "" ]; then
export PATH=/home/username/certbot_env/bin
python renew.py $1
else
echo "ERROR: missing mandatory parameter <domain> to renew!"
fi
renew.py
import sys
from certbot import main
if len(sys.argv) != 2:
print("missing mandatory parameter <domain>, pleas run from the ~/certbot_env/renew script")
sys.exit()
main.main(['certonly', '--manual', '-d', sys.argv[1]])