mfouesneau / pyphot

suite to deal with passband photometry
https://mfouesneau.github.io/pyphot/
MIT License
57 stars 18 forks source link

pyfits is not included in module dependencies #10

Closed gszasz closed 6 years ago

gszasz commented 6 years ago

After pyphot installation via pip and trying to import pyphot module via ipython I tried to run following example script copied from documentation:

import pyphot
# get the internal default library of passbands filters
lib = pyphot.get_library()
print("Library contains: ", len(lib), " filters")
# find all filter names that relates to IRAC
# and print some info
f = lib.find('irac')
for name in f:
    lib[name].info(show_zeropoints=True)

However, I have ended up with rather enigmatic traceback:

[gszasz@nova scratch]$ ./pyphot-test.py 
Traceback (most recent call last):
  File "./pyphot-test.py", line 4, in <module>
    import pyphot
ImportError: No module named 'pyphot

When I tried to import the pyphot module in ipython, I have finally received the real reason why it does not work:

[gszasz@nova ~]$ ipython
Python 2.7.5 (default, Apr 10 2015, 08:09:05) 
Type "copyright", "credits" or "license" for more information.

IPython 0.13.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import pyphot
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-748f71ce1480> in <module>()
----> 1 import pyphot

/usr/lib/python2.7/site-packages/pyphot/__init__.py in <module>()
----> 1 from .phot import (Library, Ascii_Library, HDF_Library, Filter, get_library)
      2 from .licks import (LickLibrary, LickIndex, reduce_resolution)
      3 from .ezunits import unit
      4 from .helpers import (STmag_from_flux, STmag_to_flux, extractPhotometry,
      5                       extractSEDs, fluxErrTomag, fluxToMag, magErrToFlux,

/usr/lib/python2.7/site-packages/pyphot/phot.py in <module>()
     20 from scipy.integrate import trapz
     21 
---> 22 from .simpletable import SimpleTable
     23 from .ezunits import hasUnit, unit
     24 from .vega import Vega

/usr/lib/python2.7/site-packages/pyphot/simpletable.py in <module>()
     52     from astropy.io import fits as pyfits
     53 except ImportError:
---> 54     import pyfits
     55 except:
     56     pyfits = None

ImportError: No module named pyfits
mfouesneau commented 6 years ago

You need either astropy or pyfits indeed. Astropy is in the requirements.

mfouesneau commented 6 years ago

Technically pyfits or astropy.io.fits is not required to use the library. code should now pass without error

gszasz commented 6 years ago

Thanks @mfouesneau. Your effort is highly appreciated.