Issues with istalling the CELMECH package

Dear Sir or Madam,

I have been trying to install the CELMECH package on the Rubin Data platform with the standard command:

pip3 install celmech~=1.4.0

The installation appears to be successful, but, when I try to call these libraries:

from celmech.nbody_simulation_utilities import set_time_step
from celmech.nbody_simulation_utilities import get_simarchive_integration_results
from celmech.miscellaneous import frequency_modified_fourier_transform

I got the error message below. Could you please help me with this?

Thank you,

Valerio Carruba

OSError Traceback (most recent call last)
Cell In[11], line 1
----> 1 from celmech.nbody_simulation_utilities import set_time_step
2 from celmech.nbody_simulation_utilities import get_simarchive_integration_results
3 from celmech.miscellaneous import frequency_modified_fourier_transform

File ~/.local/lib/python3.11/site-packages/celmech/init.py:38
35 pass
37 sympy.init_printing(use_latex=‘mathjax’)
—> 38 from .poincare import PoincareParticle, Poincare, PoincareHamiltonian
39 from .hamiltonian import Hamiltonian,PhaseSpaceState
40 from .canonical_transformations import CanonicalTransformation

File ~/.local/lib/python3.11/site-packages/celmech/poincare.py:8
6 from collections import MutableMapping
7 from sympy import symbols, S, binomial, summation, sqrt, cos, sin, Function,atan2,expand_trig,diff,Matrix, series
----> 8 from .hamiltonian import Hamiltonian,PhaseSpaceState
9 from .miscellaneous import poisson_bracket
10 from .disturbing_function import _p1_p2_from_k_nu, evaluate_df_coefficient_delta_expansion, get_df_term_latex

File ~/.local/lib/python3.11/site-packages/celmech/hamiltonian.py:12
10 from scipy.integrate import ode
11 import scipy.special
—> 12 from .miscellaneous import poisson_bracket
14 def _my_elliptic_e(*args):
15 if len(args) == 1:

File ~/.local/lib/python3.11/site-packages/celmech/miscellaneous.py:6
4 import warnings
5 from . import clibcelmech
----> 6 from .nbody_simulation_utilities import get_canonical_heliocentric_orbits
7 from ctypes import POINTER,c_int,c_double,c_long
9 _machine_eps = np.finfo(np.float64).eps

File ~/.local/lib/python3.11/site-packages/celmech/nbody_simulation_utilities.py:3
1 import numpy as np
2 import rebound as rb
----> 3 import reboundx as rbx
5 def set_time_step(sim,dtfactor):
6 r"""
7 Set the time step of a simulation to a fraction,dtfactor,
8 of the minimum perihelion passage timescale, defined as
(…)
15 results (see Wisdom 2015 https://ui.adsabs.harvard.edu/abs/2015AJ....150..127W/abstract_)
16 “”"

File ~/.local/lib/python3.11/site-packages/reboundx/init.py:14
12 pymodulespath = os.path.dirname(file)
13 from ctypes import *
—> 14 clibreboundx = cdll.LoadLibrary(pymodulespath + ‘/…/libreboundx’ + suffix)
16 # Version
17 version = c_char_p.in_dll(clibreboundx, “rebx_version_str”).value.decode(‘ascii’)

File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-8.0.0/lib/python3.11/ctypes/init.py:454, in LibraryLoader.LoadLibrary(self, name)
453 def LoadLibrary(self, name):
→ 454 return self._dlltype(name)

File /opt/lsst/software/stack/conda/miniconda3-py38_4.9.2/envs/lsst-scipipe-8.0.0/lib/python3.11/ctypes/init.py:376, in CDLL.init(self, name, mode, handle, use_errno, use_last_error, winmode)
373 self._FuncPtr = _FuncPtr
375 if handle is None:
→ 376 self._handle = _dlopen(self._name, mode)
377 else:
378 self._handle = handle

OSError: librebound.cpython-311-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory

Hi Valerio,

I can confirm that I get the same error message,

OSError: librebound.cpython-311-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory

if I use pip install celmech and then try to import celmech.

I’m not an expert here, but it looks like the issue is with rebound (or maybe with how celmech package defines its dependencies?). And it looks like celmech has had at least one issue with rebound in the past, and that similar errors for the rebound package have been reported… I know this isn’t satisfying but maybe try submitting an issue with the celmech team, in their repository?

Anyone else with more package installation experience please chime in here.

Hi @valeriocarruba, I got some help from @erykoff and the solution is, after using pip to install celmech, update the $LD_LIBRARY_PATH to include ~/.local/lib/python3.11/site-packages/$LD_LIBRARY_PATH.

Instructions for doing this are below, and I verified they worked for me. I’m going to mark this post as the solution but please get back in touch if this doesn’t work for you.

For use of python in a terminal.
In a terminal, execute:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.local/lib/python3.11/site-packages/

and now type python and then import celmech. It will import without failure.

For use of python in a Jupyter Notebook.
In a terminal, navigate to the notebook directory with cd ~/notebooks and then append the export statement as a new line to the .user_setups file using the following command:

echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.local/lib/python3.11/site-packages/' >> .user_setups

Verify that the line was added with more .user_setups, and it will look like this:

#!/bin/sh
# This file is expected to be found in ${HOME}/notebooks/.user_setups
#  It is a shell fragment that will be sourced during kernel startup
#  when the LSST kernel is started in a JupyterLab environment.  It runs
#  in the user context and can contain arbitrary shell code.  Exported changes
#  in its environment will persist into the JupyterLab Python environment.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/.local/lib/python3.11/site-packages/

Now open a notebook and the following import statements will execute without failure:

import celmech
from celmech import Poincare, PoincareHamiltonian
from celmech.nbody_simulation_utilities import set_time_step
from celmech.nbody_simulation_utilities import get_simarchive_integration_results
from celmech.miscellaneous import frequency_modified_fourier_transform

Dear Melissa and @erykoff,

I have checked your solution on my LSST account and it worked! Thank you very much for taking the time to solve this.

Cheers,

Valerio Carruba

1 Like