Skip to content

Interop with casatasks/casatools #251

@AlecThomson

Description

@AlecThomson

Hi there,

Apologies if this is wrong stream to report this issue. Myself and @tjgalvin have had adventures trying to install both python-casacore and casatasks/casatools on Python 3.10. I've been testing on MacOS Apple Silicon, but @tjgalvin has had similar results on linux.

First, installation with pip alone does not seem to work. I needed to resort to using a conda install. There are also issues with casatasks/casatools and how it handles matplotlib - it seems to be have been built against matplotlib<=3.5.1 and newer versions break.

Here is summary of my first stages of installation trials with minimal conda installs:

#!/usr/bin/env bash

# Create a conda environment for CASA in x86_64 architecture
CONDA_SUBDIR=osx-64 conda create -n casa_py310 python=3.10 pip ipython -y
conda activate casa_py310

# Install CASA
pip install casatasks casatools casadata python-casacore

# Test CASA
python -c "from casatasks import tclean; from casacore.tables import table; print(tclean.__doc__); print(table.__doc__)"
# Fails - Matplotlib is called incorrectly
# Traceback (most recent call last):
#   File "<string>", line 1, in <module>
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatasks/__init__.py", line 249, in <module>
#     from .plotbandpass import plotbandpass
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatasks/plotbandpass.py", line 9, in <module>
#     from .private.task_plotbandpass import plotbandpass as _plotbandpass_t
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatasks/private/task_plotbandpass.py", line 36, in <module>
#     warnings.filterwarnings("ignore",category=matplotlib.cbook.MatplotlibDeprecationWarning)
# AttributeError: module 'matplotlib.cbook' has no attribute 'MatplotlibDeprecationWarning'. Did you mean: 'VisibleDeprecationWarning'?

# Fix matplotlib
pip install "matplotlib<=3.5.1"

# Test CASA
python -c "from casatasks import tclean; from casacore.tables import table; print(tclean.__doc__); print(table.__doc__)"

# Fails - boost is not installed
# Traceback (most recent call last):
#   File "<string>", line 1, in <module>
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/__init__.py", line 60, in <module>
#     from .msutil import *
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/msutil.py", line 29, in <module>
#     from casacore.tables.table import (table, taql,
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/table.py", line 40, in <module>
#     from ._tables import (Table,
# ImportError: dlopen(/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/_tables.cpython-310-darwin.so, 0x0002): Library not loaded: @rpath/libboost_python310.dylib
#   Referenced from: <E240941C-9D5F-3C5E-BF5D-93D9C4629B0E> /Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/_tables.cpython-310-darwin.so
#   Reason: tried: '/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/tho822/mambaforge/envs/x86/lib/libboost_python310.dylib' (no such file), '/Users/tho822/mambaforge/envs/casa_py310/bin/../lib/libboost_python310.dylib' (no such file), '/Users/tho822/mambaforge/envs/casa_py310/bin/../lib/libboost_python310.dylib' (no such file), '/usr/local/lib/libboost_python310.dylib' (no such file), '/usr/lib/libboost_python310.dylib' (no such file, not in dyld cache)

# Install boost
conda install boost -y

# Test CASA
python -c "from casatasks import tclean; from casacore.tables import table; print(tclean.__doc__); print(table.__doc__)"

# casacore fails
# Traceback (most recent call last):
#   File "<string>", line 1, in <module>
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/__init__.py", line 60, in <module>
#     from .msutil import *
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/msutil.py", line 29, in <module>
#     from casacore.tables.table import (table, taql,
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/table.py", line 40, in <module>
#     from ._tables import (Table,
# ImportError: dlopen(/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casacore/tables/_tables.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '__PyTraceMalloc_NewReference'

# But casatasks works
python -c "from casatasks import tclean; print(tclean.__doc__)"
# Works

python -c "from casacore.tables import table; print(table.__doc__)"
# Fails

Next I resorted to the conda-forge build. This can seemingly work, but the order of imports matters with casatasks/casatools:

#!/usr/bin/env bash

# Create a conda environment for CASA in x86_64 architecture
CONDA_SUBDIR=osx-64 conda create -n casa_py310 python=3.10 pip ipython python-casacore -y
conda activate casa_py310
pip install "matplotlib<=3.5.1" casatasks casatools
python -c "from casatasks import tclean; from casacore.tables import table; print(tclean.__doc__); print(table.__doc__)"
# Works
python -c "from casacore.tables import table; from casatasks import tclean; print(tclean.__doc__); print(table.__doc__)"
# Fails
# Traceback (most recent call last):
#   File "<string>", line 1, in <module>
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatasks/__init__.py", line 5, in <module>
#     from casatools import logsink as _logsink
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatools/__init__.py", line 43, in <module>
#     from .image import image
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatools/image.py", line 4, in <module>
#     from .__casac__.image import image as _image
#   File "/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatools/__casac__/image.py", line 10, in <module>
#     from . import _image
# ImportError: dlopen(/Users/tho822/mambaforge/envs/casa_py310/lib/python3.10/site-packages/casatools/__casac__/_image.cpython-310-darwin.so, 0x0002): symbol not found in flat namespace '__ZN8casacore11ArrayColumnINSt3__17complexIdEEE8putSliceEyRKNS_6SlicerERKNS_5ArrayIS3_EE'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions