EC2 (Amazon Linux) certbot-auto renew error /pkg_resources.DistributionNotFound: The'virtualenv == 15.1.0'

Status

LetsEncrypt certificate renewal error on EC2 server used since 2016 (certificate also used from 2016)

environment

error contents

# certbot-auto renew
FATAL: Amazon Linux support is very experimental at present...
if you would like to work on improving it, please ensure you have backups
and then run this script again with the --debug flag!
Alternatively, you can install OS dependencies yourself and run this script
again with --no-bootstrap.
Creating virtual environment...
Traceback (most recent call last):
  File "/usr/bin/virtualenv", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3049, in <module>
    @_call_aside
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3033, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3062, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 660, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 673, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 858, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'virtualenv==15.1.0' distribution was not found and is required by the application
Traceback (most recent call last):
  File "<stdin>", line 27, in <module>
  File "<stdin>", line 19, in create_venv
  File "/usr/lib64/python2.7/subprocess.py", line 190, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['virtualenv', '--no-site-packages', '--python', '/usr/bin/python2.7', '/opt/eff.org/certbot/venv']' returned non-zero exit status 1

The following error when trying to install virtualenv == 15.1.0 with pip

Traceback (most recent call last):
  File "/usr/bin/pip", line 11, in <module>
    load_entry_point('pip==9.0.3', 'console_scripts', 'pip2.7')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 564, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2661, in load_entry_point
    raise ImportError("Entry point %r not found" % ((group, name),))
ImportError: Entry point ('console_scripts', 'pip2.7') not found

solution

In my case it works with:

# easy_install pip==9.0.3
# easy_install virtualenv==15.1.0

Digression/End of support period for Amazon Linux AMI

It's time to move to Amazon Linux 2.

Amazon Linux AMI End of Support Updates | Amazon Web Services Blog https://aws.amazon.com/jp/blogs/news/update-on-amazon-linux-ami-end-of-life/

Excerpt

--The latest version of Amazon Linux AMI (2018.03) will no longer be available with security updates on June 30, 2020. --The Amazon Linux AMI has been extended until December 31, 2020, and will continue to provide security updates and package updates as needed. --After December 31, 2020, the Amazon Linux AMI will have a new maintenance support period (continued until June 30, 2023). During this new maintenance support period --Only important and critical security updates are offered to the Amazon Linux AMI as a reduced package set. --However, we do not guarantee support for new EC2 platform capacity or new AWS features.

Recommended Posts

EC2 (Amazon Linux) certbot-auto renew error /pkg_resources.DistributionNotFound: The'virtualenv == 15.1.0'
Install pyenv on EC2 (Amazon Linux)
I'll install Ruby on EC2 (Amazon Linux2) 2020
Install Python 3.8, Pip 3.8 on EC2 (Amazon Linux 2)
Creating an AWS EC2 EC2 Instance (Amazon Linux AMI) 2
Jupyter Notebook Settings-How to use (EC2 Amazon Linux 2)
Create Amazon Linux with AWS EC2 and log in
Copy files directly from Amazon EC2 (Amazon linux) to S3
AWS EC2 2nd SSH connection to EC2 Instance (Amazon Linux2)
[AWS EC2] How to install Maven on Amazon Linux 2