Certbot dependency problem on Debian 9

Hello there! I am looking into getting a certificate for my django app and followed the certbot install instructions described here.

As additional information: I needed Python 3.7 for my project, so I compiled it from source. Have also the newest versions of pip, django and gunicorn installed with pip into a virtualenv.

Installing certbot with

sudo apt-get install python3-certbot-nginx -t stretch-backports

works but then I get the following error when running certbot:

The 'certbot==0.25.0' distribution was not found and is required by the application.

Output of apt search certbot

[...]
python3-certbot/stretch-backports,now 0.25.0-1~bpo9+1 all [installed,automatic]
main library for certbot
[...]
python3-certbot-nginx/stretch-backports,now 0.25.0-2~bpo9+1 all [installed]
Nginx plugin for Certbo

My domain is:

scheer.xyz

I ran this command:

sudo certbot --nginx
or
certbot --version
or any certbot command...

It produced this output:

Traceback (most recent call last):
  File "/usr/bin/certbot", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3088, in <module>
    @_call_aside
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 892, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'certbot==0.25.0' distribution was not found and is required by the application

My web server is (include version):
nginx 1.10.3

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

My hosting provider, if applicable, is:
vultr

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

Any help will be much appreciated!
Cheers,

Hi,

Could you please run the below command?
sudo certbot --version (apologize for the typo)

Thank you

Hello, thanks for replying!
Here it is:

sudo certbot --version

Traceback (most recent call last):
  File "/usr/bin/certbot", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3088, in <module>
    @_call_aside
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3072, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 3101, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 574, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 892, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 778, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'certbot==0.25.0' distribution was not found and is required by the application

Hi,

Could you please try to reinstall certbot?

Warning: please backup certbot directory in case of data loss.

sudo apt-get install certbot -t stretch-backports --reinstall

Thank you

Hello,

Just reinstalled it with the suggested command. I get the same output from certbot --version like before :frowning:

Thanks

Hi,

Could you please show the following command outputs?

dpkg -l | grep certbot
pip freeze

(If the output is too long, please upload it to a pastebin(online pastebin) and share a link to that pastebin)

Source: https://github.com/certbot/certbot/issues/5513

Thank you

If you run “head -1 /usr/bin/certbot”, what Python executable is it using?

if /usr/bin/python3 has been replaced, it will be lucky if Certbot is the only thing that’s malfunctioning… It looks like some sort of path issue that probably affects any Python 3 package installed via apt.

Custom Python builds are only safe if they’re completely separate from most software.

Hello guys, thanks for the replies! Here are the outputs of the requested commands:

$ dpkg -l | grep certbot

ii  certbot                           0.25.0-1~bpo9+1                all          automatically configure HTTPS using Let's Encrypt
ii  python3-certbot                   0.25.0-1~bpo9+1                all          main library for certbot
ii  python3-certbot-nginx             0.25.0-2~bpo9+1                all          Nginx plugin for Certbot

$ pip freeze

certifi==2018.10.15
pipenv==2018.10.13
virtualenv==16.0.0
virtualenv-clone==0.4.0

(virtualenv) $ pip freeze

Django==2.1.2
gunicorn==19.9.0
psycopg2-binary==2.7.5
pytz==2018.7

$ head -1 /usr/bin/certbot

#!/usr/bin/python3

It must be noted that I did indeed replace the system's default python3 bin with the following command after installing python3.7:
$ update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3 10

Now $ python3 --version gives me Python 3.7.1 instead of Debian's standard Python 3.5. I thought it was properly installed as my django app works fine, as does gunicorn and postgres through psycopg2.

Cheers,

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.