Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jupyter Notebook does not see the cadabra2 kernel, both installed via conda and the recommended way #270

Open
Fulmenius opened this issue Dec 24, 2022 · 2 comments

Comments

@Fulmenius
Copy link

Fulmenius commented Dec 24, 2022

Hello there!
I was trying to install cadabra2 so that I would be able to use it in Jupyter Notebook. First I installed it as an Anaconda package. It worked in the sense that Anaconda is aware that the package exists, and seems to understand commands like

import cadabra2 as cd
def post_process(ex):
	cd.sort_product(ex)
	cd.canonicalise(ex)
	cd.collect_terms(ex)

However, when I try something like
{\mu,\nu,\rho}::Indices(position=free). or cd.{\mu,\nu,\rho}::Indices(position=free).
Jupyter notebook raises a Python syntax error. I tried to install the standalone version of cadabra2, using the instruction from the official github repository, and it has installed successfully, but Jupyter notebook does not provide an option to run the cadabra2 kernel. What could be the problem? I use Xfce 4.16.0, distro: Linux Mint 21 Vanessa, base: Ubuntu 22.04 jammy.

P.S. Also cadabra2-gtk does not work from the terminal (fish thinks the command does not exist, although cadabra2 works just fine)
P.P.S. Also this link: https://cadabra.science/static/cadabra_in_ipython.nb.html to the inside-Python use tutorial from the official site does not work

@kpeeters
Copy link
Owner

First of all, input like

{\mu,\nu,\rho}::Indices(position=free)

is Cadabra syntax, not Python, so you should not expect that to work in a Python session. You really need either the Cadabra Jupyter kernel or Cadabra's own notebook interface cadabra2-gtk (or the command line client cadabra2).

As for your Jupyter kernel problem: you cannot mix-and-match Python distributions. If you decide you want to use Anaconda for you Python things, then everything has to come from Anaconda, otherwise you are in for a disaster. So you have two options:

  1. Install the Cadabra Jupyter kernel using the cadabra2-jupyter-kernel Conda package, see https://anaconda.org/conda-forge/cadabra2-jupyter-kernel .

  2. Disable Anaconda (or at least not enable it by default in any shell) and install the Jupyter notebook using sudo apt install jupyter-notebook and then also install Cadabra from a prebuilt .deb package or from source (prebuilt .deb packages for Mint 21 will be available in a few days). Then you have Jupyter from the Ubuntu packages and a Cadabra to go with that.

Option 2 is by far the cleanest (the apt package manager is a lot better than the conda one).

P.S. I don't know why the conda installation does not put cadabra2-gtk in your path; what happens when you type which cadabra2-gtk?

P.P.S. Thanks, I have now fixed that page.

@Fulmenius
Copy link
Author

Fulmenius commented Dec 24, 2022

Thank you for the response! I have tried installing cadabra2-jupyter-kernel, and now there is an option to choose the Cadabra kernel in jupyter notebook, but the kernel dies at a steady rate. What's worse, I can't even remove the conda installation using conda, because for some reason while building dependency tree conda runs out of memory (to the point that laptop ceases to respond to commands). I will try the recommended steps to the .deb installation when the latter will be available for Linux Mint
P.S.
which cadabra2-gtk exits with [1]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants