fermiPy / fermipy

Fermi-LAT Python Analysis Framework
http://fermipy.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
51 stars 53 forks source link

Issue with the installation. #489

Closed Noatino closed 2 years ago

Noatino commented 2 years ago

Hi guys! :)

I'm triying to install the lastest version of fermipy following the procedure described in the installation page using the procedure of the Conda-based installation.

During the process, there is not errors or warnings at the view. But, when I try to import the GTAnalysis class, I got the following error:

 from fermipy.gtanalysis import GTAnalysis
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py", line 21, in <module>
    import fermipy.gtutils as gtutils
  File "/Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/gtutils.py", line 6, in <module>
    import pyLikelihood as pyLike
  File "/Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermitools/pyLikelihood.py", line 15, in <module>
    import _pyLikelihood
ImportError: dlopen(/Users/agalv_/opt/anaconda3/envs/fermipy/lib/_pyLikelihood.so, 2): Library not loaded: @rpath/libgsl.25.dylib
  Referenced from: /Users/agalv_/opt/anaconda3/envs/fermipy/lib/libLikelihood.dylib
  Reason: image not found

Looking previous threads I ran pytest --pyargs fermipy in order to look if there is a problem and it produces the output:


=========================================================================================== test session starts ============================================================================================
platform darwin -- Python 3.9.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/agalv_
collected 68 items / 1 error                                                                                                                                                                               

================================================================================================== ERRORS ==================================================================================================
_________________________________________________ ERROR collecting opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/tests/test_gtanalysis.py _________________________________________________
ImportError while importing test module '/Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/tests/test_gtanalysis.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
opt/anaconda3/envs/fermipy/lib/python3.9/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/tests/test_gtanalysis.py:12: in <module>
    from fermipy import gtanalysis
opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/gtanalysis.py:21: in <module>
    import fermipy.gtutils as gtutils
opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/gtutils.py:6: in <module>
    import pyLikelihood as pyLike
opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermitools/pyLikelihood.py:15: in <module>
    import _pyLikelihood
E   ImportError: dlopen(/Users/agalv_/opt/anaconda3/envs/fermipy/lib/_pyLikelihood.so, 2): Library not loaded: @rpath/libgsl.25.dylib
E     Referenced from: /Users/agalv_/opt/anaconda3/envs/fermipy/lib/libLikelihood.dylib
E     Reason: image not found
============================================================================================= warnings summary =============================================================================================
opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/region/ndmap.py:3
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/region/ndmap.py:3: DeprecationWarning: Please use `label` from the `scipy.ndimage` namespace, the `scipy.ndimage.measurements` namespace is deprecated.
    from scipy.ndimage.measurements import label as ndi_label

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================================= short test summary info ==========================================================================================
ERROR opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/tests/test_gtanalysis.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================================= 1 warning, 1 error in 8.69s ========================================================================================

This is on a MacOs Big Sur, but also I recreated the error in a Linux (scientific linux) as well. I appreciate the help in advance.

Noatino commented 2 years ago

I had already solved.

Following the discussion on the Fermi-Tools Issues #https://github.com/fermi-lat/Fermitools-conda/issues/122 I did the following:

mamba create --name fermipy -c conda-forge -c fermi python=3.9 "fermitools>=2.2.0" healpy gammapy --override-channels conda activate fermipy pip install fermipy

The explain is given by @Areustle here

But doing a test, I get the following output:


% pytest --pyargs fermipy    
============================================================= test session starts ==============================================================
platform darwin -- Python 3.9.13, pytest-7.1.2, pluggy-1.0.0
rootdir: /Users/agalv_/Desktop/TT
collected 84 items                                                                                                                             

diffuse/tests/test_binning.py .                                                                                                          [  1%]
diffuse/tests/test_link_classes.py .....                                                                                                 [  7%]
diffuse/tests/test_managers.py ....                                                                                                      [ 11%]
diffuse/tests/test_name_factory.py .                                                                                                     [ 13%]
diffuse/tests/test_spectral.py .                                                                                                         [ 14%]
jobs/tests/test_analysis.py ..                                                                                                           [ 16%]
jobs/tests/test_chain.py ..                                                                                                              [ 19%]
jobs/tests/test_collect.py ..                                                                                                            [ 21%]
jobs/tests/test_file_archive.py ..                                                                                                       [ 23%]
jobs/tests/test_gtlink.py .                                                                                                              [ 25%]
jobs/tests/test_job_archive.py ..                                                                                                        [ 27%]
jobs/tests/test_plotting.py ..                                                                                                           [ 29%]
jobs/tests/test_sim.py ..                                                                                                                [ 32%]
tests/test_castro.py .x..                                                                                                                [ 36%]
tests/test_config.py ....                                                                                                                [ 41%]
tests/test_gtanalysis.py .......s.s......                                                                                                [ 60%]
tests/test_irfs.py ......                                                                                                                [ 67%]
tests/test_roi_model.py ..................                                                                                               [ 89%]
tests/test_sensitivity.py ...                                                                                                            [ 92%]
tests/test_skymap.py ..                                                                                                                  [ 95%]
tests/test_spectrum.py ....                                                                                                              [100%]

=============================================================== warnings summary ===============================================================
../../opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/region/ndmap.py:3
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/gammapy/maps/region/ndmap.py:3: DeprecationWarning: Please use `label` from the `scipy.ndimage` namespace, the `scipy.ndimage.measurements` namespace is deprecated.
    from scipy.ndimage.measurements import label as ndi_label

tests/test_gtanalysis.py::test_gtanalysis_setup
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/astropy/wcs/wcs.py:725: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2001-01-01T00:01:04.184' from MJDREF.
  Set MJD-OBS to 54682.655283 from DATE-OBS.
  Set MJD-END to 56874.155007 from DATE-END'.
    warnings.warn(

tests/test_gtanalysis.py::test_gtanalysis_write_roi
tests/test_gtanalysis.py::test_gtanalysis_write_roi
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/astropy/io/fits/column.py:2646: AstropyUserWarning: Format %s cannot be mapped to the accepted TDISPn keyword values.  Format will not be moved into TDISPn keyword.
    warnings.warn('Format {} cannot be mapped to the accepted '

tests/test_gtanalysis.py::test_gtanalysis_write_roi
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/astropy/io/fits/column.py:2646: AstropyUserWarning: Format %f cannot be mapped to the accepted TDISPn keyword values.  Format will not be moved into TDISPn keyword.
    warnings.warn('Format {} cannot be mapped to the accepted '

tests/test_gtanalysis.py::test_gtanalysis_optimize
tests/test_gtanalysis.py::test_gtanalysis_fit
tests/test_gtanalysis.py::test_gtanalysis_find_sources
tests/test_gtanalysis.py::test_gtanalysis_lightcurve
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/scipy/interpolate/_fitpack2.py:280: UserWarning: 
  The maximal number of iterations maxit (set to 20 by the program)
  allowed for finding a smoothing spline with fp=s has been reached: s
  too small.
  There is an approximation returned but the corresponding weighted sum
  of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
    warnings.warn(message)

tests/test_gtanalysis.py::test_gtanalysis_find_sources
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/scipy/interpolate/_fitpack2.py:280: UserWarning: 
  A theoretically impossible result was found during the iteration
  process for finding a smoothing spline with fp = s: s too small.
  There is an approximation returned but the corresponding weighted sum
  of squared residuals does not satisfy the condition abs(fp-s)/s < tol.
    warnings.warn(message)

tests/test_gtanalysis.py::test_gtanalysis_extension_gaussian
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/fermipy/tsmap.py:433: RuntimeWarning: invalid value encountered in double_scalars
    delta = grad / hess

tests/test_gtanalysis.py::test_gtanalysis_lightcurve
  /Users/agalv_/opt/anaconda3/envs/fermipy/lib/python3.9/site-packages/astropy/wcs/wcs.py:725: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2001-01-01T00:01:04.184' from MJDREF.
  Set MJD-OBS to 54682.655283 from DATE-OBS.
  Set MJD-END to 54884.199977 from DATE-END'.
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
====================================== 81 passed, 2 skipped, 1 xfailed, 12 warnings in 157.86s (0:02:37) =======================================

There are 2 test skipped and other one failed and I'm not sure how much I should be worried about of this. But, I think that the original issue was solved adding the --override-channels flag on the mamba instruction.

henrikef commented 2 years ago

Glad you solved it and yes, you can ignore the warnings and skipped/xfailed tests.

Noatino commented 2 years ago

Thanks @henrikef . Then I will go on without worries. Have a nice weekend.