Using Cadabra2

87 views
Skip to first unread message

Daniel Volinski

unread,
Mar 5, 2021, 3:42:20 PMMar 5
to Sage-support
Hi All,

I'm using SageMath 9.2 on Windows 10 Native with Jupyter Notebook.

My question, is there any way to use Cadabra2 on a Jupyter Notebook after installing SageMath?

I do not want to install conda or anaconda or miniconda, I just want to use Cadabra2 in the Jupyter Notebook provided by the SageMath installation and may be with minimal installation of some software.

Thanks,

Daniel Volinski


Dima Pasechnik

unread,
Mar 5, 2021, 3:49:41 PMMar 5
to sage-support
From https://cadabra.science/download.html:
Windows 10
You will need a Python3 installation from Anaconda (64-bits, Python
3.8) and a LaTeX installation (tested with MikTeX, others may work
too) in order for this to work. Install those first if you do not have
them already. The Windows port and this binary installer are in beta
right now, please report any problems. Many thanks to Dominic Price
for making this become reality.

It seems it mixes well with conda, so why not?

Otherwise, I don't think anyone here has any idea whether Cadabra2 and
Sage will work together, and if yes, how.

>
> Thanks,
>
> Daniel Volinski
>
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/14557094.2027036.1614975004314%40mail.yahoo.com.

Daniel Volinski

unread,
Mar 6, 2021, 5:23:32 AMMar 6
to sage-support
Hi Dima,

Thank you for your reply.

I already have a Python3 installation provided by the SageMath installation, I can run Python3 programs without adding anything else.
already have a LaTeX installation (MikTex) that I use with other programs. How do I proceed from here?

Thanks,

Daniel Volinski




En viernes, 5 de marzo de 2021 22:49:40 GMT+2, Dima Pasechnik <dim...@gmail.com> escribió:


On Fri, Mar 5, 2021 at 8:42 PM 'Daniel Volinski' via sage-support
<sage-s...@googlegroups.com> wrote:
>
> Hi All,
>
> I'm using SageMath 9.2 on Windows 10 Native with Jupyter Notebook.
>
> My question, is there any way to use Cadabra2 on a Jupyter Notebook after installing SageMath?
>
> I do not want to install conda or anaconda or miniconda, I just want to use Cadabra2 in the Jupyter Notebook provided by the SageMath installation and may be with minimal installation of some software.

From https://cadabra.science/download.html:
Windows 10
You will need a Python3 installation from Anaconda (64-bits, Python
3.8) and a LaTeX installation (tested with MikTeX, others may work
too) in order for this to work. Install those first if you do not have
them already. The Windows port and this binary installer are in beta
right now, please report any problems. Many thanks to Dominic Price
for making this become reality.

It seems it mixes well with conda, so why not?

Otherwise, I don't think anyone here has any idea whether Cadabra2 and
Sage will work together, and if yes, how.

>
> Thanks,
>
> Daniel Volinski
>
>
> --
> You received this message because you are subscribed to the Google Groups "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsub...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsub...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/CAAWYfq2ZFE2vViOxPf0CZiUW_hUc3yj--2ZxQkwJwRLUt-VHcg%40mail.gmail.com.

Dima Pasechnik

unread,
Mar 6, 2021, 5:30:27 AMMar 6
to sage-support


On Sat, 6 Mar 2021, 10:23 'Daniel Volinski' via sage-support, <sage-s...@googlegroups.com> wrote:
Hi Dima,

Thank you for your reply.

I already have a Python3 installation provided by the SageMath installation, I can run Python3 programs without adding anything else.
already have a LaTeX installation (MikTex) that I use with other programs. How do I proceed from here?

We don't know how to install Cadabra2.

IMHO this is a question for Cadabra2 people: "I have a Python3 installation, and I want to run Cadabra2 on top of it".

To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/1467251413.81492.1615008723279%40mail.yahoo.com.

Daniel Volinski

unread,
Mar 6, 2021, 9:57:25 AMMar 6
to sage-s...@googlegroups.com

Daniel Volinski

unread,
Mar 7, 2021, 4:10:54 AMMar 7
to Sage-support
Hi Dima,

I asked the same question on the Cadabra support site, they don't know either.

Daniel Volinski



Dima Pasechnik

unread,
Mar 7, 2021, 4:29:47 AMMar 7
to sage-support
I must say I don't understand what you mean by "use Cadabra2 on a Jupyter Notebook", is it even possible?
The following does not read like it's supported by Cadabra2:

but it's not clear how to use it, whether it's working at all etc.
Do they have a working Jupyter kernel, which can be used in a system Jupyter notebook?

In principle, Sage can use system Jupyter notebook (although whether it's try on Windows, I don't know)
So if this is all working there should be no issue. 

Daniel Volinski

unread,
Mar 8, 2021, 2:28:19 AMMar 8
to sage-support
Hi Dima,

This is a page in the Cadabra site: Cadabra: use with Jupyter

I just want to calculate some General relativity stuff using Cadabra on a Jupyter Notebook as shown in their picture.

Thanks,

Daniel Volinski




Dima Pasechnik

unread,
Mar 8, 2021, 9:22:57 AMMar 8
to sage-support
On Mon, Mar 8, 2021 at 7:28 AM 'Daniel Volinski' via sage-support
<sage-s...@googlegroups.com> wrote:
>
> Hi Dima,
>
> This is a page in the Cadabra site: Cadabra: use with Jupyter
>
> I just want to calculate some General relativity stuff using Cadabra on a Jupyter Notebook as shown in their picture.

I'm able to build Cadabra2 in SageMath environment (at sage --buildsh
prompt, that is)
on Debian Linux. This way it should be possible to use it with Sage's
Jupyter notebook.

But on Windows, well, probably much harder...
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/902868743.800695.1615184278261%40mail.yahoo.com.

Kasper Peeters

unread,
Mar 12, 2021, 5:51:56 PMMar 12
to sage-support
Cadabra author here. On Unix, the Cadabra build/install process installs a Jupyter kernel, which works with SageMath installed from the binary distribution (may need some PYTHONPATH setting, but nothing more). On Windows, the build process using Visual Studio is relatively simple, but getting everything to see all required libraries is a never-ending horror story. Maybe someone on the SageMath team responsible for the Windows port can help out; I have no resources to properly support Windows.

The alternative is to run the lot in WSL and then install a binary distribution of Cadabra; that is known to work from first-hand experience using a non-SageMath Jupyter installation, but I have no doubt it can be made to work with the one supplied by SageMath. You can still connect to the Jupyter kernel from your Windows browser that way.

Henri Girard

unread,
Mar 13, 2021, 2:04:32 AMMar 13
to sage-s...@googlegroups.com

Thank you very much, I am using next month ubuntu 21.04 an working with sage 5.2, just install sudo apt install cadabra2 start sage in jupyter notebook and to display latex at the beginning write only once  in a cell

%display latex

from cadabra2 import *

from IPython.display import display, Math, Latex

For example :

%display latex
ex=Ex(r"A_{m n} B^{m n}");ex

and voila ! lol

Daniel Volinski

unread,
Mar 13, 2021, 6:26:35 AMMar 13
to sage-s...@googlegroups.com
Hi All,

Is it possible to "translate" all that to Windows 10?

Thanks,

Daniel Volinski

Kasper Peeters

unread,
Mar 13, 2021, 7:52:05 AMMar 13
to sage-support

>    %display latex

>   from cadabra2 import *

That only uses the Cadabra python module, which means that you do not have access to all the Cadabra specific syntax for declaring expressions and properties. Nothing wrong with that, but if you want the full experience, you need the Cadabra kernel (which in effect pre-processes the input before feeding it to Python).

Kasper

Dima Pasechnik

unread,
Mar 13, 2021, 8:47:43 AMMar 13
to sage-support
On Fri, Mar 12, 2021 at 10:51 PM Kasper Peeters
<kasper....@gmail.com> wrote:
>
> Cadabra author here. On Unix, the Cadabra build/install process installs a Jupyter kernel, which works with SageMath installed from the binary distribution (may need some PYTHONPATH setting, but nothing more).

It seems that the Jupyter part of Cadabra appends /usr/local to
cmake's DESTDIR for a reason I don't understand.
A Cadabra bug, maybe? (I don't know enough of cmake to be certain).
It least that's what I got when I tried installing Cadabra into SageMath's venv,
which has the convention that the install prefix is <SAGE_ROOT>/local
(with SAGE_ROOT the location of the
root of SageMath install); I've set DESTDIR=<SAGE_ROOT>/local and got
(some parts of) Cadabra installed into DESTDIR/usr/local - which is
not what's needed.

Dima
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/c9a86815-5fa7-4670-97e7-37ff0c63802dn%40googlegroups.com.

Kasper Peeters

unread,
Mar 13, 2021, 10:34:44 AMMar 13
to sage-support
I am happy to stand corrected, but shouldn't you in that case set `CMAKE_INSTALL_PREFIX` to the empty string? Things get installed into `${DESTDIR}${CMAKE_INSTALL_PREFIX}`. If you do not set `CMAKE_INSTALL_PREFIX`, it defaults to `/usr/local`.

Kasper

Dima Pasechnik

unread,
Mar 13, 2021, 11:19:59 AMMar 13
to sage-support
On Sat, Mar 13, 2021 at 3:34 PM Kasper Peeters <kasper....@gmail.com> wrote:
>
> I am happy to stand corrected, but shouldn't you in that case set `CMAKE_INSTALL_PREFIX` to the empty string? Things get installed into `${DESTDIR}${CMAKE_INSTALL_PREFIX}`. If you do not set `CMAKE_INSTALL_PREFIX`, it defaults to `/usr/local`.

Right, but I don't understand at what point CMAKE_INSTALL_PREFIX has
to be set, and how.
CMAKE_INSTALL_PREFIX is a "cmake-variable", as opposed to DESTDIR,
which is an environment
variable used in cmake-produced makefiles.
(As I said, I have little understanding of cmake...)

Dima
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/3670842d-2e0d-4360-8c5f-e0c3a68e2482n%40googlegroups.com.

Henri Girard

unread,
Mar 13, 2021, 4:52:42 PMMar 13
to sage-s...@googlegroups.com

Yes sorry you are right

Henri

Kasper Peeters

unread,
Mar 14, 2021, 3:29:34 PMMar 14
to sage-support
Run cmake as

    cmake -DCMAKE_INSTALL_PREFIX=<SAGE_ROOT>/local

and do not set `DESTDIR`. The `DESTDIR` variable is meant for package creation, not to set the final installation location; see https://www.gnu.org/prep/standards/html_node/DESTDIR.html for more details.

Dima Pasechnik

unread,
Mar 14, 2021, 4:55:48 PMMar 14
to sage-support
On Sun, Mar 14, 2021 at 7:29 PM Kasper Peeters <kasper....@gmail.com> wrote:
>
> Run cmake as
>
> cmake -DCMAKE_INSTALL_PREFIX=<SAGE_ROOT>/local
>
> and do not set `DESTDIR`. The `DESTDIR` variable is meant for package creation, not to set the final installation location; see https://www.gnu.org/prep/standards/html_node/DESTDIR.html for more details.

Thanks. I forgot that cmake-speak for parameters is "variables".
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/93a8d6db-0a78-4554-8a0f-2e59d37f494cn%40googlegroups.com.

Daniel Volinski

unread,
Apr 14, 2021, 5:22:01 AMApr 14
to sage-support
Hi All,

Has this been resolved? Can I use Cadabra2 on a SageMath installation on Windows 10?

Thanks,

Daniel Volinski

Dima Pasechnik

unread,
Apr 14, 2021, 8:31:13 AMApr 14
to sage-support
On Wednesday, April 14, 2021 at 10:22:01 AM UTC+1 Daniel Volinski wrote:
Hi All,

Has this been resolved? Can I use Cadabra2 on a SageMath installation on Windows 10?

no, not really - your best bet is to use WSL2 and build SageMath and Cadabra from source there.
Then you have a chance of them talking to each other on Windows 10.

Otherwise, you can try to install Cadabra into SageMath Cygwin installation for Windows,
but this might be much harder.
(SageMath does not run "natively" on Windows)

HTH
Dima

Dima Pasechnik

unread,
Apr 14, 2021, 8:33:59 AMApr 14
to sage-support
On Friday, March 12, 2021 at 10:51:56 PM UTC kasper....@gmail.com wrote:
Cadabra author here. On Unix, the Cadabra build/install process installs a Jupyter kernel, which works with SageMath installed from the binary distribution (may need some PYTHONPATH setting, but nothing more). On Windows, the build process using Visual Studio is relatively simple, but getting everything to see all required libraries is a never-ending horror story. Maybe someone on the SageMath team responsible for the Windows port can help out; I have no resources to properly support Windows.

The most "native" way to run  SageMath on Windows is to use Cygwin. It doesn't run natively, it needs POSIX fork etc.
Not sure if you'd want to port Cababra to Cygwin, it might be quite a bit of work for little gain.
Reply all
Reply to author
Forward
0 new messages