Repository navigation
Open
Description
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__)"
# FailsNext 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
Labels
No labels
Activity
AlecThomson commentedon Nov 30, 2023
On linux, using that last script, I get these errors:
and
AlecThomson commentedon Aug 27, 2024
Hey all - just wondering if anyone has had a chance to look at this?
Tagging @gijzelaerr @tammojan for some visibility.
tammojan commentedon Aug 27, 2024
Hi, thanks for the ping. I think trying to have both the CASA python bindings and the python-casacore python bindings to casacore is near impossible. That is due to the underlying casacore. If you load two python bindings, two casacores will be loaded, but the symbols of these two will shadow each other. If the versions are binary incompatible (which is probably the case) this will in the best case lead to segfaults, in a good case you get the error on importing.
In theory this should be solvable, but on the short term we have no plans to work on this. So if you use casatools, you'd have to access the table also through casatools - or use a trick with multiple venvs or so.
AlecThomson commentedon Aug 27, 2024
Thanks so much @tammojan. Really appreciate the feedback on this. I'll give the
casatools.tablefunctionality some testing to see if we can get things working.AlecThomson commentedon Jun 19, 2026
Hey @tammojan - sorry to bump this very old ticket! I heard (and now tested) that this seems to be resolved for Python >= 3.11. Is this expected? Is the underlying fix expected to be stable?
tammojan commentedon Jun 19, 2026
I'm afraid the answers to both your questions is no. The underlying issue is not resolved, casatools and python-casacore both install a separate casacore library. These are not expected to be binary (ABI) compatible, but in some cases they may be. So if it works, it's a matter of luck.
AlecThomson commentedon Jun 19, 2026
Thanks @tammojan - just discovered that the hard way tinkering 😭 Thanks for confirming, though!
For reference I had: