How do I stop DeprecationWarning for Python 2.6?
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:
- https://community.letsencrypt.org/t/redhat-centos-6-x-users-need-python-2-7/2190
- https://github.com/h2oai/h2o-2/wiki/installing-python-2.7-on-centos-6.3.-follow-this-sequence-exactly-for-centos-machine-only
- https://wiki.centos.org/AdditionalResources/Repositories/SCL
Edit: Other sources mention the need to install centos-release-SCL
in order to install Python 2.7
Related videos on Youtube
Chloe
Updated on September 18, 2022Comments
-
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 over 7 yearsThis gave an error:
Error getting repository data for ius, repository not found
-
GiantTree over 7 yearsI've found a slightly different solution. See the edit
-
Chloe over 7 yearsOK 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 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 over 7 yearsThat 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/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
-
Chloe about 7 yearsThis isn't a good idea because everytime certbot updates itself (like every 2 weeks) then it will overwrite the script.
-
Chloe about 7 yearsUnfortunately, package python27 is empty!
yum info python27
;Size : 0.0