amuse icon indicating copy to clipboard operation
amuse copied to clipboard

Obsolete installation message when importing via amuse.lab

Open LourensVeen opened this issue 4 months ago • 0 comments

Describe the bug When I made the new build system, I made it so that if you import a code that isn't available from amuse.community.<code>, you get a nice error that tells you how to install it, depending on whether we're in a venv or a conda environment.

What I failed to notice was that you can also install from amuse.lab, and that that has its own error message, which currently reads:

Traceback (most recent call last):
  File "/data2/lveen/amuse-2025.9.0/examples/textbook/gravity_minimal.py", line 26, in <module>
    gravity_minimal(N, t_end)
    ~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/data2/lveen/amuse-2025.9.0/examples/textbook/gravity_minimal.py", line 8, in gravity_minimal
    gravity = Hermite()
  File "/data2/lveen/miniforge3/envs/Amuse-env/lib/python3.14/site-packages/amuse/lab.py", line 133, in __init__
    raise Exception(
        "failed import, code {0} not available, maybe it needs to be "
        "(pip) installed?".format(name))
Exception: failed import, code hermite not available, maybe it needs to be (pip) installed?

We don't want people to pip install anymore. For comparison, when importing from amuse.community it says:

Traceback (most recent call last):
  File "/data2/lveen/amuse-2025.9.0/examples/textbook/gravity_minimal.py", line 1, in <module>
    from amuse.community.hermite import Hermite
  File "/data2/lveen/miniforge3/envs/Amuse-env/lib/python3.14/site-packages/amuse/community/hermite/__init__.py", line 1, in <module>
    from .interface import Hermite
  File "/data2/lveen/miniforge3/envs/Amuse-env/lib/python3.14/site-packages/amuse/community/hermite/interface.py", line 4, in <module>
    HermiteInterface = load_code("hermite", "HermiteInterface")
  File "/data2/lveen/miniforge3/envs/Amuse-env/lib/python3.14/site-packages/amuse/support/import_helper.py", line 38, in load_code
    raise ImportError(msg) from None
ImportError: Error: hermite is not installed, so we cannot use it. To install hermite, go to the terminal, make sure that the 'Amuse-env' conda environment is active and that you are in the amuse source directory, then install the code using './setup install amuse-hermite' and restart your script or reload the kernel.

To Reproduce from amuse.lab import Hermite with Hermite not installed.

Expected behavior The second error message above to be displayed

LourensVeen avatar Nov 04 '25 16:11 LourensVeen