How do I stop DeprecationWarning for Python 2.6?

8,270

Solution 1

I fixed it by installing scl and using this in the crontab

@daily scl enable python27 "/root/certbot-auto renew --quiet"


[root@server ~]# python --version
Python 2.6.6
[root@server ~]# python2 --version
Python 2.6.6
[root@server ~]# scl enable python27 "python --version"
Python 2.7.13

Solution 2

CentOS 6.x (all releases of CentOS 6) comes with Python 2.6, which is, as you found out, outdated and not supported anymore.

Luckily you can install Python 2.7 besides 2.6:

yum -y install centos-release-SCL
yum -y install python27

Then you need to replace the Python version used by Let's Encrypt with the new Python 2.7 like this:

git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
sed -i "s|--python python2|--python python2.7|" letsencrypt-auto
./letsencrypt-auto --verbose

I did not find this out myself, so all credit goes to eva2000 of the Let's Encrypt Community.

You may need to replace letsencrypt-auto with cerbot-auto as the original answer is from 2015.

Sources:

Edit: Other sources mention the need to install centos-release-SCL in order to install Python 2.7

Share:
8,270

Related videos on Youtube

Chloe
Author by

Chloe

Updated on September 18, 2022

Comments

  • Chloe
    Chloe over 1 year

    I have to run this command daily in a cron to refresh certifications.

    # /root/certbot-auto renew --quiet
    /root/.local/share/letsencrypt/lib/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
      DeprecationWarning
    

    It's always mailing me the error. How do I upgrade my python to avoid this error? I already ran yum update but everything is up to date.

    Installed Packages
    Name        : python
    Arch        : x86_64
    Version     : 2.6.6
    

    Reference: Certbot: https://certbot.eff.org/#centos6-apache

    CentOS release 6.8 (Final)

  • Chloe
    Chloe over 7 years
    This gave an error: Error getting repository data for ius, repository not found
  • GiantTree
    GiantTree over 7 years
    I've found a slightly different solution. See the edit
  • Chloe
    Chloe over 7 years
    OK I see 'software collections' is way to have multiple versions installed at once, like rvm for Ruby. Why can't I just upgrade Python to 2.7 and get rid of 2.6?
  • GiantTree
    GiantTree over 7 years
    @Chloe I don't know, I don't use CentOS, but for some reason the OS has scripts that require Python 2.6.
  • Chloe
    Chloe over 7 years
    That didn't work: # sed -i "s|--python python2|--python python2.7|" certbot-auto and # ./certbot-auto renew --quiet yields /root/.local/share/letsencrypt/lib/python2.6/site-packages/c‌​ryptography/__init__‌​.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
  • Chloe
    Chloe about 7 years
    This isn't a good idea because everytime certbot updates itself (like every 2 weeks) then it will overwrite the script.
  • Chloe
    Chloe about 7 years
    Unfortunately, package python27 is empty! yum info python27; Size : 0.0