使用 Let's Encrypt 的 Python 问题

使用 Let's Encrypt 的 Python 问题

当尝试使用以下命令设置我的证书时:

./letsencrypt-auto --apache -d example.com

我从 Python 收到此错误:

dpkg: dependency problems prevent configuration of python-virtualenv:
 python-virtualenv depends on python-pkg-resources; however:
  Package python-pkg-resources is not configured yet.
 python-virtualenv depends on python-setuptools; however:
  Package python-setuptools is not configured yet.
 python-virtualenv depends on python (>= 2.7); however:
  Package python is not configured yet.
 python-virtualenv depends on python (<< 2.8); however:
  Package python is not configured yet.
 python-virtualenv depends on python:any (>= 2.7.1-0ubuntu2); however:
  Package python is not configured yet.

dpkg: error processing package python-virtualenv (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python-minimal
 python
 python-dev
 python-pkg-resources
 python-setuptools
 python-virtualenv
E: Sub-process /usr/bin/dpkg returned an error code (1)

导致出现一系列问题。我尝试:sudo dpkg --configure python,但显然 Python-minimal 也未配置。尝试“sudo dpkg --configure python-minimal”并得到以下结果:

Setting up python-minimal (2.7.5-5ubuntu3) ...
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/local/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/usr/local/lib/python2.7/compileall.py", line 16, in <module>
    import struct
  File "/usr/local/lib/python2.7/struct.py", line 1, in <module>
    from _struct import *
ImportError: No module named _struct
dpkg: error processing package python-minimal (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 python-minimal

我尝试删除它们并重新安装,但没有成功。

答案1

解决了我的问题,这个帖子有答案:https://ubuntuforums.org/showthread.php?t=2333185

编辑以下文件。

nano /var/lib/dpkg/info/python-minimal.postinst

#! /bin/sh
set -e


python2.7 -m compileall /usr/share/python/ >/dev/null

#! /bin/sh
set -e


python -m compileall /usr/share/python/ >/dev/null

然后

apt-get install python2.7-minimal

相关内容