Skip to content

Table.read on FITS file triggers PyYAML import #7783

@cdeil

Description

@cdeil

In Gammapy some of our tests are failing now in the build where we check basic functionality without optional dependencies like PyYAML installed:
https://travis-ci.org/gammapy/gammapy/jobs/422455259#L2801

The problem is that Table.read on a FITS file will try to import yaml and throw an ImportError, even if I mention format="fits".

Minimal example that fails with Astropy master as of today( 9a99f5e ).

>>> from astropy.table import Table
>>> Table.read('/Users/deil/work/code/gammapy-extra/datasets/hess-dl3-dr1/obs-index.fits.gz', format='fits')
Traceback (most recent call last):
  File "/Users/deil/work/code/astropy/astropy/table/meta.py", line 321, in get_header_from_yaml
    import yaml
ModuleNotFoundError: No module named 'yaml'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/deil/work/code/astropy/astropy/table/table.py", line 2554, in read
    out = io_registry.read(cls, *args, **kwargs)
  File "/Users/deil/work/code/astropy/astropy/io/registry.py", line 517, in read
    data = reader(*args, **kwargs)
  File "/Users/deil/work/code/astropy/astropy/io/fits/connect.py", line 200, in read_table_fits
    astropy_native=astropy_native)
  File "/Users/deil/work/code/astropy/astropy/io/fits/connect.py", line 277, in read_table_fits
    t = _decode_mixins(t)
  File "/Users/deil/work/code/astropy/astropy/io/fits/connect.py", line 97, in _decode_mixins
    info = meta.get_header_from_yaml(lines)
  File "/Users/deil/work/code/astropy/astropy/table/meta.py", line 323, in get_header_from_yaml
    raise ImportError('`import yaml` failed, PyYAML package '
ImportError: `import yaml` failed, PyYAML package is required for serializing mixin columns

I think given that PyYAML is an optional dependency, and FITS support is built into Astropy, this should be considered a bug?

cc @saimn @taldcroft

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions