[AstroPy] IERS issue again

E. Madison Bray erik.m.bray at gmail.com
Sun Nov 22 13:03:36 EST 2020

Hi Nicolas,

Apologies for the late response. A few things:

1) I'm sorry you hate this particularly annoying problem.  It's especially
prevalent on Windows, where Python itself ships some SSL root certificates
to use to verify SSL resources on the internet.  Unfortunately if your
Python installation is too old, the certificates it ships with might be

2) It looks like you're using a very old version of Astropy, on Python 2.7,
which is deprecated.  As soon as possible you should upgrade to Python 3;
Python 3.7 is probably the most stable for most software you use, if not
Python 3.8.

3) That said, you might be stuck on Python 2.7 for reasons I cannot know.
And even if you were on a newer version of Python it might still be a
problem.  This is a known issue in Astropy which has a fix at [1] which
will be included in Astropy v4.3.0

4) There is a potential workaround, though mind you I have not tested it
since I don't have Python 2.7 on Windows anymore.  The workaround is to use
the certifi [2] package, which provides up-to-date SSL root certificates in
a manner which is easy to use by Python [3].  Its source releases should
still work on Python 2.7.  The next step is you need to "monkey patch" the
`ssl` module of Python to ensure that it always uses the certificates from
certifi.  Here's a way you can do that; you would run this in your script
before trying to do anything with astropy.time:

First you need to install certifi:

> python2.7 -m pip install certifi

Then in your Python code:

import certifi
import ssl
orig_create_default_context = ssl.create_default_context

def create_default_context(**kwargs):
    kwargs['cafile'] = certifi.where()
    return orig_create_default_context(**kwargs)

ssl.create_default_context = create_default_context

I believe this should work, but again I stress that it is untested.  Give
it a try and see if it resolves the issue for you, and please report back
here whether it works or not.

Nevertheless I would encourage you to upgrade to Python 3 as soon as


[1] https://github.com/astropy/astropy/pull/10434
[2] https://pypi.org/project/certifi/

On Wed, Nov 18, 2020 at 7:26 PM Nicola Montecchiari <
omega.centauri at gmail.com> wrote:

> Hello everybody,
> after some months I am getting again an error while trying to connect to
> the IERS.
> Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:19:08) [MSC v.1500 32
> bit (Intel)] on win32
> astropy==2.0.16
> numpy==1.16.6
> >>> from astropy.time import Time
> >>> t = Time('2016:001')
> >>> t.ut1
> WARNING: failed to download
> https://datacenter.iers.org/data/9/finals2000A.all and
> ftp://cddis.gsfc.nasa.gov/pub/products/iers/finals2000A.all, using local
> IERS-B: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify
> failed (_ssl.c:727)>;<urlopen error ftp error: timed out>
> [astropy.utils.iers.iers]
> <Time object: scale='ut1' format='yday' value=2016:001:00:00:00.082>
> Is this a known issue?
> Thanks a lot for your help
> Nicola
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Mail
> priva di virus. www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
> <#m_-2678403154958117125_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/astropy/attachments/20201122/05d6ef2c/attachment.html>

More information about the AstroPy mailing list