You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

树莓派4(Raspbian 11)安装Certbot for Nginx后遇PackageNotFoundError

解决Raspbian Bullseye中Certbot执行报错问题

问题原因

你当前处于Python虚拟环境(venv)中,通过apt安装的Certbot是绑定系统Python环境的。虚拟环境与系统Python环境完全隔离,虚拟环境内未安装Certbot相关包,因此执行命令时会触发PackageNotFoundError。

解决方案

方案1:退出虚拟环境执行Certbot

直接退出当前虚拟环境,使用系统环境运行Certbot:

deactivate
certbot --version

如需配置Nginx证书,直接执行sudo certbot --nginx即可。

方案2:在虚拟环境内安装Certbot

如果必须在虚拟环境中使用Certbot,需通过pip在虚拟环境内重新安装:

  1. 确保处于激活的虚拟环境中,执行:
pip install certbot certbot-nginx
  1. 安装完成后,即可在虚拟环境内正常运行Certbot命令:
certbot --version

方案3:直接指定系统Python路径运行Certbot

如果不想退出虚拟环境,也可以直接调用系统Python来执行Certbot:

sudo /usr/bin/python3 /usr/bin/certbot --version

内容的提问来源于stack exchange,提问作者Jano

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 03:27:16