Failed to run certbot-auto successfully on CentOS 6.5

I am running a CentOS 6.5 with Apache. I downloaded the certbot-auto and when I ran the command it does install few things but failed at the end with this error

Error: Command ‘[’/opt/eff.org/certbot/venv/bin/python3’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1

This is the complete error log

Bootstrapping dependencies for RedHat-based OSes that will use Python3… (you can skip this with --no-bootstrap)
yum is /usr/bin/yum
yum is hashed (/usr/bin/yum)
Failed to set locale, defaulting to C
Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile

  • base: centos.bhs.mirrors.ovh.net
  • epel: fedora-epel.mirrors.tds.net
  • extras: mirror2.evolution-host.com
  • rpmforge: mirror.team-cymru.org
  • updates: mirror2.evolution-host.com
    Package gcc-4.4.7-18.el6.x86_64 already installed and latest version
    Package augeas-libs-1.0.0-10.el6.x86_64 already installed and latest version
    Package openssl-1.0.1e-57.el6.x86_64 already installed and latest version
    Package openssl-devel-1.0.1e-57.el6.x86_64 already installed and latest version
    Package libffi-devel-3.0.5-3.2.el6.x86_64 already installed and latest version
    Package redhat-rpm-config-9.0.3-51.el6.centos.noarch already installed and latest version
    Package ca-certificates-2017.2.14-65.0.1.el6_9.noarch already installed and latest version
    Package python34-3.4.5-4.el6.x86_64 already installed and latest version
    Package python34-devel-3.4.5-4.el6.x86_64 already installed and latest version
    Package python34-tools-3.4.5-4.el6.x86_64 already installed and latest version
    Package 1:mod_ssl-2.2.15-60.el6.centos.6.x86_64 already installed and latest version
    Nothing to do
    Bootstrapping dependencies for RedHat-based OSes that will use Python3… (you can skip this with --no-bootstrap)
    yum is /usr/bin/yum
    yum is hashed (/usr/bin/yum)
    Failed to set locale, defaulting to C
    Loaded plugins: fastestmirror
    Setting up Install Process
    Loading mirror speeds from cached hostfile
  • base: centos.bhs.mirrors.ovh.net
  • epel: mirror.math.princeton.edu
  • extras: mirror2.evolution-host.com
  • rpmforge: mirror.team-cymru.org
  • updates: mirror2.evolution-host.com
    Package gcc-4.4.7-18.el6.x86_64 already installed and latest version
    Package augeas-libs-1.0.0-10.el6.x86_64 already installed and latest version
    Package openssl-1.0.1e-57.el6.x86_64 already installed and latest version
    Package openssl-devel-1.0.1e-57.el6.x86_64 already installed and latest version
    Package libffi-devel-3.0.5-3.2.el6.x86_64 already installed and latest version
    Package redhat-rpm-config-9.0.3-51.el6.centos.noarch already installed and latest version
    Package ca-certificates-2017.2.14-65.0.1.el6_9.noarch already installed and latest version
    Package python34-3.4.5-4.el6.x86_64 already installed and latest version
    Package python34-devel-3.4.5-4.el6.x86_64 already installed and latest version
    Package python34-tools-3.4.5-4.el6.x86_64 already installed and latest version
    Package 1:mod_ssl-2.2.15-60.el6.centos.6.x86_64 already installed and latest version
    Nothing to do
    Creating virtual environment…
    Error: Command ‘[’/opt/eff.org/certbot/venv/bin/python3’, ‘-Im’, ‘ensurepip’, ‘–upgrade’, ‘–default-pip’]’ returned non-zero exit status 1

My system (CentOS 6.9 ):
python 2.6.6 && python 3.4.5
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)
pip 9.0.1 from /usr/lib/python3.4/site-packages/pip-9.0.1-py3.4.egg (python 3.4)

If running

[SERVER1@~]# /opt/eff.org/certbot/venv/bin/python3 -Im ensurepip --upgrade --default-pip
Ignoring indexes: Simple index
Requirement already up-to-date: setuptools in /opt/eff.org/certbot/venv/lib/python3.4/site-packages
Requirement already up-to-date: pip in /opt/eff.org/certbot/venv/lib/python3.4/site-packages
Traceback (most recent call last):
File "/usr/lib64/python3.4/runpy.py", line 170, in _run_module_as_main
"main", mod_spec)
File "/usr/lib64/python3.4/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib64/python3.4/ensurepip/main.py", line 4, in
ensurepip._main()
File "/usr/lib64/python3.4/ensurepip/init.py", line 209, in _main
default_pip=args.default_pip,
File "/usr/lib64/python3.4/ensurepip/init.py", line 116, in bootstrap
_run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
File "/usr/lib64/python3.4/tempfile.py", line 709, in exit
self.cleanup()
File "/usr/lib64/python3.4/tempfile.py", line 713, in cleanup
_shutil.rmtree(self.name)
File "/usr/lib64/python3.4/shutil.py", line 468, in rmtree
_rmtree_safe_fd(fd, path, onerror)
File "/usr/lib64/python3.4/shutil.py", line 390, in _rmtree_safe_fd
onerror(os.listdir, path, sys.exc_info())
File "/usr/lib64/python3.4/shutil.py", line 387, in _rmtree_safe_fd
names = os.listdir(topfd)
OSError: [Errno 22] Invalid argument: '/tmp/tmpbxcj6qt1'

If I try to use os.listdir in a python shell:

[SERVER1@~]# /opt/eff.org/certbot/venv/bin/python3
Python 3.4.5 (default, Dec 11 2017, 16:57:19)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
$ import os
$ os.listdir('/tmp/tmpbxcj6qt1')
['setuptools-20.10.1-py2.py3-none-any.whl', 'pip-8.1.1-py2.py3-none-any.whl']

I really don't understand why I can use os.listdir in python shell only...

I had the same issue, it looks it was the locale in my case, i just had to run this command:

export LC_ALL=C

then try to execute the certbot-auto command again, I hope it helps you.

export LC_ALL=C

doesn’t work on my CentOS box. same error.

Any hint by developers? Issue is urgent since I need to renew some certificates.

A workaround working for me on CentOS 6.9:

$ sudo scl enable python27 './certbot-auto renew'

change at /usr/lib/python3.4/shutil.py

line 387:

try:
    names = os.listdir(topfd)
except OSError as err:

TO => :

try:
    names = os.listdir(path)
except OSError as err:

and all will work proper.

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