Installing Astronify via homebrew on RSP notebooks

Hi, I was interested in trying to make some sonifications of DP0 data on the RSP with Astronify (Astronify) and tried installing with pip install astronify but got the following error:

In file included from src/engine/ad_portaudio.c:21:
include/ad_portaudio.h:25:10: fatal error: portaudio.h: No such file or directory
25 | #include “portaudio.h”
| ^~~~~~~~~~~~~
compilation terminated.
error: command ‘/opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-7.0.1/bin/x86_64-conda-linux-gnu-cc’ failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyo
Running setup.py clean for pyo
Building wheel for thinkx (setup.py) … done
Created wheel for thinkx: filename=thinkx-1.1.3-py3-none-any.whl size=59923 sha256=b1997fce5dd49c8e2587a5dc959166837bb4c243847e904e4021727d7de80ea8
Stored in directory: /home/rwclarke/.cache/pip/wheels/26/b4/cc/8819524bab9b9a5206fcd073d76db5dc5b7f6c37f186974e0e
Successfully built astronify thinkx
Failed to build pyo
ERROR: Could not build wheels for pyo, which is required to install pyproject.toml-based projects

I think I need to first install portaudio but it looks like portaudio is only available via the homebrew package manager, not pip. Is there a way to install and use homebrew on the RSP?

It looks like the portaudio dependency is coming in via the python package pyo, and according to their documentation if you build pyo itself with the flag --minimal, it will skip the code that depends on portaudio. I’m guessing that will be ok for your usage since portaudio mostly deals with sending audio to or from the sound card, which won’t work in the RSP environment anyways (you’ll want to write out to audio files and then play/download those).

You say you tried pip install astronify but I assume you are actually doing pip install --user astronify

@ctslater regarding “which won’t work in the RSP environment anyways (you’ll want to write out to audio files and then play/download those)”, do you know, is there no way to play an audio file from within the RSP, or just no way with portaudio? The CST does want to create sonification tutorials that don’t require the user to download the results; will that be possible soon or in the future maybe?

I was able to play an audio file in a notebook with IPython.display.Audio(filename="test_file.wav"). portaudio is used when you want to play audio on the same computer that you’re running the code on, but on the RSP the code runs in a data center somewhere, so instead you need to use IPython to interface with the browser to play the audio.

3 Likes

After following Colin’s suggestions (thank you!), I was able to play the file from one of the tutorials in the astronify documentation.

I pushed the first draft of the notebook illustrating the above in the branch PREOPS-3368 of tutorial_notebooks

Steps in a terminal in the cloud RSP:

git clone https://github.com/belangeo/pyo.git
ls
cd pyo/
python setup.py install --user --minimal
cd ..
pip install --user astronify
python -m pip install lightkurve --upgrade --user

I installed lightkurve just to try the astronify tutorial, but I’ll discuss the next steps with Riley. We had talked about starting with a lightcurve from DP0.2.

@rwclarke – can we mark Colin’s reply about IPython.display.Audio as the solution to this forum topic? It sounds (pun not intended…) like this did work for Andres on RSP. Thanks…

@ctslater I’m trying to reproduce again at data.lsst.cloud using the instructions above from last year. But now import astronify gives:

ImportError: libsndfile.so.1: cannot open shared object file: No such file or directory

I’m wondering what happened since I verified that things were working, but it seems that it now needs GitHub - libsndfile/libsndfile: A C library for reading and writing sound files containing sampled audio data. . Is that correct? I’m using weekly 2023_47 at the cloud RSP (recommended).