radio-astro-tools / spectral-cube

Library for reading and analyzing astrophysical spectral data cubes
http://spectral-cube.rtfd.org
BSD 3-Clause "New" or "Revised" License
98 stars 65 forks source link

Export to glue: no module named 'glue.app.qt' #926

Open HealthyPear opened 2 weeks ago

HealthyPear commented 2 weeks ago

I installed glue on an arm64 machine but in a CONDA_SUBDIR=osx-64 environment. I installed via pip resulting in

# Name                    Version                   Build  Channel
glue-core                 1.21.1                   pypi_0    pypi
glue-qt                   0.3.1                    pypi_0    pypi
glue-vispy-viewers        1.2.2                    pypi_0    pypi
glueviz                   1.3.0                    pypi_0    pypi
glue-qt                   0.3.1                    pypi_0    pypi
pyqt                      5.15.9          py312hd74d816_5    conda-forge
pyqt5-sip                 12.12.2         py312he36337a_5    conda-forge
qt-main                   5.15.8              h63f3aef_26    conda-forge
qtconsole                 5.6.0                    pypi_0    pypi
qtpy                      2.4.1                    pypi_0    pypi
spectral-cube             0.6.5                    pypi_0    pypi

as soon as I call the to_glue method I get this error

Traceback (most recent call last):
  File "/Users/michele/Software/3D_rendering_radio_data/test_glue.py", line 27, in <module>
    masked_slab.to_glue(name=None, glue_app=None, dataset=None, start_gui=True)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/michele/Software/miniforge3/envs/radio_3d_renderer_glue/lib/python3.13/site-packages/spectral_cube/spectral_cube.py", line 2427, in to_glue
    from glue.app.qt import GlueApplication
ModuleNotFoundError: No module named 'glue.app.qt'

I am instead able to launch glue alone

HealthyPear commented 2 weeks ago

I fixed this by changing the import code in to_glue as below,

try:
    from glue.app.qt import GlueApplication
except ImportError: 
    from glue_qt.app.application import GlueApplication
from glue.core import DataCollection, Data
from glue.core.coordinates import coordinates_from_header
try:
    from glue.viewers.image.qt.data_viewer import ImageViewer
except ImportError:
    from glue_qt.viewers.image import ImageViewer
except ImportError:
    from glue.viewers.image.qt.viewer_widget import ImageWidget as ImageViewer

if you want I can open a PR.

HealthyPear commented 2 weeks ago

I can't really make use of this because the only thing I need (iso surfaces) is not available (anymore) from there, but at least I manages to make it work.

e-koch commented 2 weeks ago

thanks @HealthyPear! We'd appreciate you opening a PR.