certbot设置ssl,错误“No module named'ConfigParser'”

我正在设置我的网站通过certbot使用https。

我按照这里的方向

我运行wgetchmod没有任何问题,但是当我执行时:

 ./certbot-auto 

我得到以下错误:

 Setting up gyp (0.1+20150913git1f374df9-1ubuntu1) ... Traceback (most recent call last): File "/usr/bin/pycompile", line 35, in from debpython.version import SUPPORTED, debsorted, vrepr, \ File "/usr/share/python/debpython/version.py", line 24, in from ConfigParser import SafeConfigParser ImportError: No module named 'ConfigParser' dpkg: error processing package gyp (--configure): subprocess installed post-installation script returned error exit status 1 Setting up python-virtualenv (15.0.1+ds-3) ... Traceback (most recent call last): File "/usr/bin/pycompile", line 35, in from debpython.version import SUPPORTED, debsorted, vrepr, \ File "/usr/share/python/debpython/version.py", line 24, in from ConfigParser import SafeConfigParser ImportError: No module named 'ConfigParser' dpkg: error processing package python-virtualenv (--configure): subprocess installed post-installation script returned error exit status 1 dpkg: dependency problems prevent configuration of node-gyp: node-gyp depends on gyp (>= 0.1+20150913git1f374df9); however: Package gyp is not configured yet. dpkg: error processing package node-gyp (--configure): dependency problems - leaving unconfigured dpkg: dependency problems prevent configuration of npm: npm depends on node-gyp (>= 0.10.9); however: Package node-gyp is not configured yet. dpkg: error processing package npm (--configure): dependency problems - leaving unconfigured Setting up trash-cli (0.12.9.14-2) ... 

我主要关注这个错误:

ImportError:没有名为“ConfigParser”的模块

但找不到任何解决办法。

我该如何解决这个错误?

PS我想知道这是否与不同的默认python设置有关,但使用ln -sf /usr/bin/python2.7 / usr / local / bin / python尝试2.7和3.5都无济于事。

首先,根据前面的回答build议移除Python 3是一个可怕的想法,虽然它有一个修复你的特定问题的机会很小,但更有可能创造更多的,因为任何程序依赖于它会崩溃。

其次,您的问题源自对您的系统所做的修改,而这个修改是不应该发生的。 python是为了向后兼容而默认链接到python2 (见PEP 394 ),由Ubuntu上的python-minimal提供(参见文件列表 )。

我会build议删除破损的软件包,重新安装pythonpython-minimalpython3python3-minimal运行的东西沿线:

 sudo apt update # Get an up-to-date list of available packages sudo apt autoclean # Remove partial packages sudo apt clean # Remove package cache to force redownload sudo apt install --reinstall python python-minimal python3 python3-minimal 

如果任何破坏的软件包拒绝通过apt被删除,你可以使用sudo dpkg --remove -force --force-remove-reinstreq $BROKEN_PACKAGE_NAMES (当然你应该用实际的破坏软件包replacevariables)。 注意,这将几乎卸载任何东西,所以不要试图卸载你认为对你的系统至关重要的软件包。

一旦你修复了你的系统Python,再次运行certbot-auto

ConfigParser是一个buildin模块,但是它已经被python 3变成了小写的configparser 。你正在用python3运行一个python2脚本。

摆脱python3和只安装python2应该可以解决你的问题。 我个人使用脱水,这也可能是一个选项。