Welcome to Cadabra Q&A, where you can ask questions and receive answers from other members of the community.
+1 vote

Hi Kasper, Thanks for the quick update. I've tried to run the latest version of cadabra2 but I get this run time error

Cadabra 2.5.11 (build 3796.22211b1d23 dated 2025-04-08)
Copyright (C) 2001-2025  Kasper Peeters <info@cadabra.science>
Traceback (most recent call last):
  File "<input>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/Users/leo/tmp2//opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cadabra2_defaults.py'

I had no problems compiling the code. Here is what I did

git clone https://github.com/kpeeters/cadabra2
cd cadabra2/
git checkout devel
cmake -DENABLE_MATHEMATICA=OFF -DCMAKE_INSTALL_PREFIX:PATH=/Users/leo/tmp2/ ..
mkdir build
make install

export PATH=/Users/leo/tmp2/bin/:$PATH

I chose to install to ~/tmp2 just for testing. I've done this mant times before and b=nvere had this problem. Any thoughts? Cheers, Leo ps. Santa was very busy over Xmas so no surprise that a few gremlins got into the system :)

related to an answer for: simple substitute hits wrong target
in Bug reports by (2.1k points)

1 Answer

+1 vote
 
Best answer

I don't think that we can make this work again, and I actually don't think this worked as you thought before. The python packaging logic is so terribly convoluted and broken that it is probably not a good idea to try to install Cadabra in CMAKE_INSTALL_PREFIX that does not also have the python stuff. Previously, it would just install half in /Users/leo/tmp2/bin/ and the python stuff elsewhere in /opt/homebrew/, I think.

Just sorting this out has probably already taken at least 30% of the Cadabra development time (with packaging for Windows the remaining 70%...) so it is unlikely that I wlll find the energy to give this another attempt soon.

If you just want to test, create a Python virtual environment and install Cadabra while you have that active.

by (85.9k points)
selected by

Hi Kasper, I thought that might be the case. I've also run into Python problems mostly to do with compatability issues between various versions of packages. But Conda seems to keep that sorted.

I'll go back to not using CMAKE_INSTALL_PREFIX.

Okay, done. And the compile/install went fine but I had two problems (now fixed).

Running cadabra2 from the command line gave me

Cadabra 2.5.11 (build 3798.56252610b8 dated 2025-04-08)
Copyright (C) 2001-2025  Kasper Peeters <info@cadabra.science>
Traceback (most recent call last):
  File "<input>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local//opt/homebrew/opt/python@3.13/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cadabra2_defaults.py'

I fixed that by creating a soft link

cd /usr/local
sudo ln -s /opt opt

Then cadabra2 reported

Traceback (most recent call last):
  File "/usr/local/bin//cadabra2", line 139, in <module>
    prefix, res = convert_line(line, sh.convert_data, True)
    ^^^^^^^^^^^
ValueError: too many values to unpack (expected 2)

I fixed that by deleting prefix, from the left hand side (on lines 88 and 139 in the cadabra2 script).

I can now run cadabra2 from the command line.

EDIT: The above hack is wrong. I have reverted back to the original version of cadabra2. That runs as expected.

This strongly suggests that you have an old cadabra2*.so somewhere which gets picked up first.

I will double-check the installation process; the fact that there is a /usr/local/opt/homebrew/... mentioned above is not right.

Mix conda and homebrew python and you have a recipe for disaster... Conda sounds nice in theory but there are so many issues, it is just not funny anymore.

Hi Kasper, I've double checked and yes I still get the wrong result. Cheers, Leo

See my comment to your other question: it is definitely picking up an old version of the cadabra2*.so python module. Let me double-check the installation procedure first though before you run more experiments.

(you can delete that old cadabra2*.so of course)

I didn't intend to install python via Homebrew. I used Conda miniforge to setup my Python environment. But when I used Homebrew to install some other package it installed its own version of Python. Not sure how I can stop that.

I might try a complete reinstall of everything on my laptop (I've got a virtual maching installed).

I just did a search under /opt and found three :)

./homebrew/lib/python3.12/site-packages/cadabra2.cpython-312-darwin.so
./homebrew/lib/python3.13/site-packages/cadabra2.cpython-313-darwin.so
./homebrew/Cellar/cadabra2/2.5.8/lib/python3.12/site-packages/cadabra2.cpython-313-darwin.so

Okay, fixed.

I moved the /opt/homebrew/Cellar/cadabra2 out of the way (I renamed it).

I also reverted to the original cadabra2 script (to undo my local hack re convert_line).

Now I get the correct results!

So maybe the problem is that I had the hombrew verson of Cadabra in place when I did the compile from source.

I think I'll stick with the compile from source option. It works :)

...