pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.08k stars 298 forks source link

Better error info for missing package #2036

Open zxdawn opened 2 years ago

zxdawn commented 2 years ago

Describe the bug

I tried to read the MODIS_L2 HDF files and got this error:

[ValueError: No supported files found]()

When I turned the debug on, I found out the problem:

[DEBUG: 2022-02-27 17:00:48 : satpy.readers.yaml_reader] Reading ('[/home/xin/miniconda3/lib/python3.9/site-packages/satpy/etc/readers/modis_l2.yaml]()',)
[INFO: 2022-02-27 17:00:48 : satpy.readers] Cannot use ['[/home/xin/miniconda3/lib/python3.9/site-packages/satpy/etc/readers/modis_l2.yaml]()']
[DEBUG: 2022-02-27 17:00:48 : satpy.readers] while constructing a Python object
cannot find module 'satpy.readers.modis_l2' (No module named 'pyhdf')
  in "[/home/xin/miniconda3/lib/python3.9/site-packages/satpy/etc/readers/modis_l2.yaml]()", line 12, column 18
[WARNING: 2022-02-27 17:00:48 : satpy.readers] Don't know how to open the following files: {'../data/modis/MOD06_L2.A2019223.0245.061.2019223133650.hdf'}

Expected behavior

It's better to raise the missed package error instead of the missing reader error. Or, making the pyhdf the necessary installed package?

Environment Info:

djhoese commented 2 years ago

You're not wrong. I think we used to have a good reason for doing this like this, but right now I can't think of why. The best thing I can come up with is if users are using the automatic functions like find_files_and_readers, we don't want them to get a ton of warnings about readers they don't have dependencies for when they only care about a few readers. I suppose we could use warnings.catch_warnings in functions like find_files_and_readers to hide those warnings when we don't want to see them, but otherwise by default we see them.

Pull requests welcome :man_shrugging: