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

Hello,

Trouble running Cadabra 2 and generating output with the system described below:

OS: WSL 2 [Windows Subsystem for Linux 2] Ubuntu 18.04 on Windows 10 x64

Python 3.7.7.
Installation type: Anaconda 3

Cadabra2 download and installed using conda as per instructions

conda list cadabra
packages in environment at /home/audrius/anaconda3:
Name Version Build Channel
cadabra2-jupyter-kernel 2.2.9 h6bb024c_0 kpeeters

conda list sympy
packages in environment at /home/audrius/anaconda3:
Name Version Build Channel
sympy 1.5.1 py37_0

conda list jupyter
packages in environment at /home/audrius/anaconda3:
Name Version Build Channel
cadabra2-jupyter-kernel 2.2.9 h6bb024c0 kpeeters
jupyter 1.0.0 py37
7
jupyterclient 6.1.2 py0
jupyterconsole 6.1.0 py0
jupytercore 4.6.3 py370
jupyterlab 1.2.6 pyhf63ae980
jupyterlab
server 1.1.0 py_0

Is there another conda package or packages that I should check?

Using the MS VS Code IDE, I start the Jupyter server, select the "Cadabra" kernel option.
I then run the cell containing the example code from "Using Cadabra for tensor computations in General Relativity" by L. Brewin, "1. Hello metric connection", but no output is generated, just a new cell is created. Also, the Cadabra kernel state stays "Idle".

I've attached a screenshot below:

VS Code IDE. Cadabra kernel

asked in Installation trouble by

That's a combination I had not tried yet... ;-) Have you tried whether running it using Jupyter's own notebook server works? (so starting with 'jupyter notebook' and then using the web browser notebook interface? I suspect the answer is that that does not work either, but I'd like to have it confirmed before we dig any further.

1 Answer

0 votes

"Have you tried whether running it using Jupyter's own notebook server works?"

No, I had not done so.

While WSL 2 is a fully functional Linux OS, not an emulator, it is command-line only - there is no GUI desktop and no browser. With a addition of an X-server on the Windows 10 side, such as VcXsrv, one can display matplotlib output, in a separate window, generated in VS Code running on WSL side.Which is more than sufficient for scientific computing using numpy/sympy/numba/etc.

[update in following comment]

answered by (200 points)
edited by

After a bit of investigation, I was able to start a standalone Jupyter Notebook on the WSL 2 side
and run an .ipynb file, using the Cadabra 2 kernel, in a browser on the Windows 10 side.

I've listed the steps below should it be of interest to other users.

1/ WLS 2 side. If not already installed, install wslu.

https://github.com/wslutilities/wslu

As I'm running Ubuntu 18.04,

sudo apt update
sudo apt install ubuntu-wsl
wslview --register

The last command registers wslu as the browser.

2/ WLS 2 side. In ~/.bashrc, append a line setting the BROWSER environment variable

export BROWSER=wslview

3/ WLS 2 side. cd to the directory with the .ipynb file(s) of interest and enter the standard
command

jupyter notebook --no-browser

A message such as the following should be generated, with no "tty" error message.

[I 05:18:22.050 NotebookApp] Writing notebook server cookie secret to /home/audrius/.local/share/jupyter/runtime/notebookcookiesecret
[I 05:18:24.296 NotebookApp] JupyterLab extension loaded from /home/audrius/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 05:18:24.296 NotebookApp] JupyterLab application directory is /home/audrius/anaconda3/share/jupyter/lab
[I 05:18:24.305 NotebookApp] Serving notebooks from local directory: /mnt/c/projects/hamiltonian
[I 05:18:24.305 NotebookApp] The Jupyter Notebook is running at:
[I 05:18:24.305 NotebookApp] http://localhost:8888/?token=d2192d44165fd0f7a3162f6e6528425c838d27edb7b8d681
[I 05:18:24.306 NotebookApp] or http://127.0.0.1:8888/?token=d2192d44165fd0f7a3162f6e6528425c838d27edb7b8d681
[I 05:18:24.306 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 05:18:24.317 NotebookApp]

To access the notebook, open this file in a browser:
file:///home/audrius/.local/share/jupyter/runtime/nbserver-29930-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=d2192d44165fd0f7a3162f6e6528425c838d27edb7b8d681
or http://127.0.0.1:8888/?token=d2192d44165fd0f7a3162f6e6528425c838d27edb7b8d681

4/ Windows 10 side. Start the browser and enter the above url with token into the address bar.

In this case, I would enter

http://127.0.0.1:8888/?token=d2192d44165fd0f7a3162f6e6528425c838d27edb7b8d681

The browser should now display the WSL 2 side directory with the .ipynb files of interest.

5/ Windows 10 side. Left-click on the .ipynb file of interest. A new browser tab/window should
appear with the kernel set to Cadabra. Run the cell to view the Latex/MathML output in the browser.


WSL 2 side only. No success in running Cadabra in VS Code.

So in summary, output works in Jupyter's own notebook, just not in VS Code?

That is correct.

Ok, thanks. I don't have time right now to dig into this, but I have opened an issue on the Cadabra issue tracker so it doesn't get lost:

https://github.com/kpeeters/cadabra2/issues/196

Thank you.

No idea if this would be simpler to implement, but could Cadabra 2 be converted to a Python package that one would import into a Python program as one does with Sympy?

Will also mention the VS Code extension Markdown+Math which be of use in displaying equation output:

https://marketplace.visualstudio.com/items?itemName=goessner.mdmath

...