看到你,梁松远的博客

位置 » 主页 » 学海无涯 » 使用certbot-auto安装报错Certbot has problem setting up the virtual environment.

使用certbot-auto安装报错Certbot has problem setting up the virtual environment.

 今天准备拿certbot-auto给服务器上几个网站更新https证书,本来已经安装过一遍了,以为没什么问题,结果执行

./certbot-auto renew

更新命令,结果就收到了报错提示:

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff; min-height: 13.0px} span.s1 {font-variant-ligatures: no-common-ligatures}

Downloading http://mirrors.aliyun.com/pypi/packages/28/ca/cf17ceca2d8caf8f93ea844bd862ad3f595a796648958ae6c5faf846e354/letsencrypt-0.7.0.tar.gz

Collecting certbot==0.27.1 (from -r /tmp/tmp.0Ajz2PN4DF/letsencrypt-auto-requirements.txt (line 204))

  Could not find a version that satisfies the requirement certbot==0.27.1 (from -r /tmp/tmp.0Ajz2PN4DF/letsencrypt-auto-requirements.txt (line 204)) (from versions: 0.6.0, 0.7.0, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.10.0, 0.10.1, 0.10.2, 0.11.0, 0.11.1, 0.12.0, 0.13.0, 0.14.0, 0.14.1, 0.14.2, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.18.1, 0.18.2, 0.19.0, 0.20.0, 0.21.0, 0.21.1, 0.22.0, 0.22.1, 0.22.2, 0.23.0, 0.24.0, 0.25.0, 0.25.1, 0.26.0, 0.26.1)

No matching distribution found for certbot==0.27.1 (from -r /tmp/tmp.0Ajz2PN4DF/letsencrypt-auto-requirements.txt (line 204))

=====================================================

 

Certbot has problem setting up the virtual environment.

 

We were not be able to guess the right solution from your pip 

output.

 

Consult https://certbot.eff.org/docs/install.html#problems-with-python-virtual-environment

for possible solutions.

You may also find some support resources at https://certbot.eff.org/support/ .

开始以为是python的版本不对,导致创建不了virtual environment,服务器上安装了python2.6和python3.4,于是将本身的python2.6更换成python3.4

 

mv /usr/bin/python /usr/bin/python2.6

ln -s /usr/bin/python3.4 /usr/bin/python

更换完成后,再执行一遍./certbot-auto renew 结果还是报同样的错误,上面报错说无法We were not be able to guess the right solution from your pip output.,以为是pip不对,于是由将pip升级一下

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures}

wget https://bootstrap.pypa.io/get-pip.py

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures}

python get-pip.py

查看新安装的pip是什么

 

whereis pip

输出

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures}

pip: /usr/bin/pip2.6 /usr/bin/pip3.4 /usr/bin/pip

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures} p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures}

 

于是将/usr/bin/pip删掉

rm -f /usr/bin/pip

重新软链一个

ln -s /usr/bin/pip3.4 /usr/bin/pip

 

再执行一遍./certbot-auto renew 结果还是报同样的错误,这是为什么呢?再回头看看上面的错误,还有一个被我忽略的错误:

Could not find a version that satisfies the requirement certbot==0.27.1 (from -r /tmp/tmp.0Ajz2PN4DF/letsencrypt-auto-requirements.txt (line 204)) (from versions: 0.6.0, 0.7.0, 0.8.0, 0.8.1, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.10.0, 0.10.1, 0.10.2, 0.11.0, 0.11.1, 0.12.0, 0.13.0, 0.14.0, 0.14.1, 0.14.2, 0.15.0, 0.16.0, 0.17.0, 0.18.0, 0.18.1, 0.18.2, 0.19.0, 0.20.0, 0.21.0, 0.21.1, 0.22.0, 0.22.1, 0.22.2, 0.23.0, 0.24.0, 0.25.0, 0.25.1, 0.26.0, 0.26.1)

 

No matching distribution found for certbot==0.27.1 (from -r /tmp/tmp.0Ajz2PN4DF/letsencrypt-auto-requirements.txt (line 204))

错误竟然是找不到对应的版本,上面一堆version,唯独没有0.27.1,这是怎么回事?然后再往上看,pypi源是mirrors.aliyun.com,阿里云啊,这个坑货,原来是阿里云镜像搞的鬼,阿里云的镜像并不是实时同步官方仓库的,往往都落后很多,这回是一个教训,果断放弃阿里云的镜像源。

rm -f /root/.pip/pip.conf 

 

至此,问题得到了解决。

总结:造成本次问题的罪魁祸首是阿里云镜像源更新滞后,导致certbot-auto 自动升级失败

解决办法:删掉 /root/.pip/pip.conf 或者改个名字