certbot on Ubuntu 12.04: No module named pip.__main__

Ubuntu 12.04 is far old, and not mantained anymore. But many peopole still use it, and still use certbot-auto, the generic bash script used to obtain Letsencrypt certs.

The script updates itself every time it’s run, but unfortunately the current version (0.32.0 onwards) won’t run anymore with the following error:

root@server-web:/usr/local/bin# ./certbot-auto certificates
 Upgrading certbot-auto 0.31.0 to 0.34.0…
 Replacing certbot-auto…
 Creating virtual environment…
 Installing Python packages…
 /opt/eff.org/certbot/venv/bin/python: No module named pip.main; 'pip' is a package and cannot be directly executed
 Traceback (most recent call last):
   File "/tmp/tmp.9vckIRVgVf/pipstrap.py", line 177, in 
   File "/tmp/tmp.9vckIRVgVf/pipstrap.py", line 149, in main
     pip_version = StrictVersion(check_output([python, '-m', 'pip', '--version'])
   File "/usr/lib/python2.7/subprocess.py", line 544, in check_output
     raise CalledProcessError(retcode, cmd, output=output)
 subprocess.CalledProcessError: Command '['/opt/eff.org/certbot/venv/bin/python', '-m', 'pip', '--version']' returned non-zero exit status 1

To make it work again you can use these commands, as suggested on LE’s forum by user ericb2038:

cd /usr/local/bin
rm ./certbot-auto*
wget https://raw.githubusercontent.com/certbot/certbot/75499277be6699fd5a9b884837546391950a3ec9/certbot-auto
chmod +x ./certbot-auto
./certbot-auto --no-self-upgrade

This way the script will work again, but you must always run it with the –no-self-upgrade option.

Here’s a tip to make it permanent (like if certbot is being run automatically by something else, like ISPConfig). Edit /usr/local/bin/certbot-auto and add the following at line 99:


(which is before the following line:)

if [ $BASENAME = "letsencrypt-auto" ]; then

This will force the above option at every run.

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Solve : *
23 + 17 =

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.