Problem with Certbot Pip Package

My domain is: https://codedragon.dev

I ran this command: certbot --version

It produced this output: Traceback (most recent call last): File "/home/deblad/.local/bin/certbot", line 6, in <module> from certbot.main import main ModuleNotFoundError: No module named 'certbot'

My web server is (include version): Nginx/1.18.0

The operating system my web server runs on is (include version): Debian 10

My hosting provider, if applicable, is: Linode

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): Certbot 1.9.0

I have been using the certbot package from the Debian repositories, but I noticed that it was heavily out-of-date including the fact that it was missing some, in my opinion, important security updates: Certbot version 0.31.0-1. Thus, I decided to switch to the Pip package, but I have had issues with it using dependencies from the apt package that I tried to purge from the system with sudo apt purge certbot python3-certbot-nginx. After getting it fixed so that I could finally install the Pip version of certbot, I ran into the issue in that it is not in my $PATH anymore. So I just created an alias in ~/.bash_aliases using the command alias certbot='sudo ~/.local/bin/certbot' Well now it complains that an import module isn't installed which is really confusing. When I rerun pip install certbot I get the following output:

Requirement already satisfied: certbot in ./.local/lib/python3.7/site-packages (1.9.0)
Requirement already satisfied: acme>=1.8.0 in ./.local/lib/python3.7/site-packages (from certbot) (1.9.0)
Requirement already satisfied: zope.interface in /usr/lib/python3/dist-packages (from certbot) (4.3.2)
Requirement already satisfied: josepy>=1.1.0 in /usr/lib/python3/dist-packages (from certbot) (1.1.0)
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from certbot) (2019.1)
Requirement already satisfied: ConfigArgParse>=0.9.3 in /usr/lib/python3/dist-packages (from certbot) (0.13.0)
Requirement already satisfied: cryptography>=1.2.3 in /usr/lib/python3/dist-packages (from certbot) (2.6.1)
Requirement already satisfied: parsedatetime>=1.3 in /usr/lib/python3/dist-packages (from certbot) (2.4)
Requirement already satisfied: distro>=1.0.1 in ./.local/lib/python3.7/site-packages (from certbot) (1.5.0)
Requirement already satisfied: pyrfc3339 in /usr/lib/python3/dist-packages (from certbot) (1.1)
Requirement already satisfied: zope.component in /usr/lib/python3/dist-packages (from certbot) (4.3.0)
Requirement already satisfied: configobj in /usr/lib/python3/dist-packages (from certbot) (5.0.6)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from certbot) (40.8.0)
Requirement already satisfied: PyOpenSSL>=0.15.1 in /usr/lib/python3/dist-packages (from acme>=1.8.0->certbot) (19.0.0)
Requirement already satisfied: requests-toolbelt>=0.3.0 in /usr/lib/python3/dist-packages (from acme>=1.8.0->certbot) (0.8.0)
Requirement already satisfied: requests[security]>=2.6.0 in /usr/lib/python3/dist-packages (from acme>=1.8.0->certbot) (2.21.0)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from acme>=1.8.0->certbot) (1.12.0)
Requirement already satisfied: idna>=2.0.0 in /usr/lib/python3/dist-packages (from requests[security]>=2.6.0->acme>=1.8.0->certbot) (2.10)
1 Like

Also please note that pip install certbot-nginx also produces the following output:

Requirement already satisfied: certbot-nginx in ./.local/lib/python3.7/site-packages (1.9.0)
Requirement already satisfied: PyOpenSSL in /usr/lib/python3/dist-packages (from certbot-nginx) (19.0.0)
Requirement already satisfied: pyparsing>=1.5.5 in /usr/lib/python3/dist-packages (from certbot-nginx) (2.2.0)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from certbot-nginx) (40.8.0)
Requirement already satisfied: certbot>=1.6.0 in ./.local/lib/python3.7/site-packages (from certbot-nginx) (1.9.0)
Requirement already satisfied: acme>=1.4.0 in ./.local/lib/python3.7/site-packages (from certbot-nginx) (1.9.0)
Requirement already satisfied: zope.interface in /usr/lib/python3/dist-packages (from certbot-nginx) (4.3.2)
Requirement already satisfied: pyrfc3339 in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (1.1)
Requirement already satisfied: ConfigArgParse>=0.9.3 in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (0.13.0)
Requirement already satisfied: distro>=1.0.1 in ./.local/lib/python3.7/site-packages (from certbot>=1.6.0->certbot-nginx) (1.5.0)
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (2019.1)
Requirement already satisfied: cryptography>=1.2.3 in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (2.6.1)
Requirement already satisfied: zope.component in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (4.3.0)
Requirement already satisfied: configobj in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (5.0.6)
Requirement already satisfied: parsedatetime>=1.3 in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (2.4)
Requirement already satisfied: josepy>=1.1.0 in /usr/lib/python3/dist-packages (from certbot>=1.6.0->certbot-nginx) (1.1.0)
Requirement already satisfied: requests[security]>=2.6.0 in /usr/lib/python3/dist-packages (from acme>=1.4.0->certbot-nginx) (2.21.0)
Requirement already satisfied: requests-toolbelt>=0.3.0 in /usr/lib/python3/dist-packages (from acme>=1.4.0->certbot-nginx) (0.8.0)
Requirement already satisfied: six>=1.9.0 in /usr/lib/python3/dist-packages (from acme>=1.4.0->certbot-nginx) (1.12.0)
Requirement already satisfied: idna>=2.0.0 in /usr/lib/python3/dist-packages (from requests[security]>=2.6.0->acme>=1.4.0->certbot-nginx) (2.10)
1 Like

Also I have considering removing some of those packages in the /usr/lib/python3/dist-packages directory since that is what worked when my apt purge command failed (sudo rm -rf /usr/lib/python3/dist-packages/certbot* for the record), but I am afraid that may break my system since I don't know if other debian packages require those as dependencies.

1 Like

Welcome Back, Tyler :slightly_smiling_face:

I thought I remembered your last topic from your avatar, but I reviewed it just to be sure.

2 Likes

Remind me: Are you using Raspbian?

You switched to nginx?

I didn't think I saw anything previously about you trying to use the snap version of certbot. Might save you a lot of headaches if you can.

1 Like

Yes, I switched from Apache to Nginx. Also I don't use snaps... I am using the python3-pip package of certbot. Or at least I am trying to.

1 Like

For the record, my switch to Nginx comes with its own headache and so my site is horribly broken rn. But my switch to Nginx is why the root domain has no CSS if you go to it.

1 Like

Did you completely remove the apt certbot first?

sudo apt-get remove certbot

I see the purge, but you also mentioned existing dependencies. Version 0.31.0-1 has some serious bugs.

1 Like

Yes. The Purge is supposed to remove the package in addition to its configuration files and related stuff. I am just going to redo the OS completely because, apt is being a piece of shit like it normally likes to do (ugh why I switched to Arch on my desktop). While it is "production", it is my own personal server so isn't as important.

2 Likes

:grin:

I feel you. Things can become a right mess very quickly. Certbot is switching exclusively to snaps I believe, so I'm not sure avoiding it will be beneficial in the long run.

1 Like

Snaps, in my opinion are horrible. I don't know if Pip is officially supported by EFF, but it should be because Pip is Amazing. (I guess you could say that it is the python version of node.js if my understanding of node.js is correct)

1 Like

This is a headache as well... Originally I used the debian package for this, but discovered that there was an official debian repo maintained by the Nginx project itself. Switching from the main debian repo to the Nginx repo was a headache too.
1 Like

Did you see this?

1 Like

I didn't run pip as superuser.

1 Like

The first sentence is a warning about not using pip at all. You are welcome to try it of course. We like the daring. :blush:

The link I gave also provides some additional information in the Operating System Packages section. You did mention Arch...

1 Like

I am not using Arch on my server. And also I understand what it was saying, but pip is nice especially on a Debian-based system which is what I run.

1 Like

I think I misinterpreted part of your rant earlier. :upside_down_face:

I'm not exactly sure what else to suggest given your direction, but I know someone who might...

@_az

If you're around, I think you can probably get Tyler (CodeDragon5793) on a good path here.

1 Like

Can I install certbot with docker?

2 Likes

Yep.

2 Likes