Run certbot showing ValueError: ('Expected version spec in'

I'm having problem with running certbot which i believe occured after installing some python package. Does anyone ever meet the same issue?

My domain is: not related with DNS

I ran this command: certbot

It produced this output:

certbot
Traceback (most recent call last):
  File "/usr/bin/certbot", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3007, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 728, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 631, in resolve
    requirements.extend(dist.requires(req.extras)[::-1])
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2489, in requires
    dm = self._dep_map
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2700, in _dep_map
    self.__dep_map = self._compute_dependencies()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2724, in _compute_dependencies
    parsed = next(parse_requirements(distvers))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 30, in <lambda>
    next = lambda o: o.next()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2839, in parse_requirements
    line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2807, in scan_list
    raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', 'charset-normalizer ~=2.0.0', 'at', ' ~=2.0.0')

My web server is (include version): Nginx 1.20.1

The operating system my web server runs on is (include version): Centos 7.8.2003

My hosting provider, if applicable, is: DigitalOcean

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 --version showing error, but from rpm info, i use certbot-1.11.0-1.el7

Additional information i use Python 2.7.5 and python3 3.6.8

I am guessing that somebody ran pip install requests on this system, and it's taking precedence over the python2-requests package, which is breaking Certbot.

FWIW we recommend using the Certbot snap to avoid these kinds of issues.

I am guessing that you are going to need to do something like:

sudo pip uninstall requests urllib3
sudo yum -y reinstall python-chardet python-requests python-urllib3

but be forewarned, I do not know if this is going to break other things on your system.

thanks, i tried it, however it lead to another error

Traceback (most recent call last):
  File "/usr/bin/certbot", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 3007, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 728, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 626, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: requests>=2.6.0

Ah, I made a mistake. The second command should have been something else. Try:

yum -y reinstall python-requests python-urllib3

If that's still not working, then let me know what the output of these is:

rpm -qa python-requests
pip freeze | grep requests
1 Like

thanks for the hint @_az , i managed to solve the problem by :

sudo pip uninstall requests urllib3
sudo yum -y reinstall python-chardet python-urllib3
sudo yum -y install python-requests
#if necessary reinstall the certbot
yum reinstall certbot python2-certbot python2-certbot-nginx

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