sage-10.0 not working in Jupyter Lab

233 views
Skip to first unread message

Luis Finotti

unread,
May 29, 2023, 2:39:33 PM5/29/23
to sage-support
I have just installed version 10.0 from source (in Debian Sid).  Everything seems to work fine, but the usual method to add Sage to Jupyter Lab does not work.

I created a symlink as usual:

$ ll /home/finotti/.local/share/jupyter/kernels
Permissions Size User    Group   Date Modified Name
drwxr-xr-x     - finotti finotti 28 Mar 13:20  magma/
drwxr-xr-x     - finotti finotti 28 Mar 11:38  python3/
lrwxrwxrwx    62 finotti finotti 28 Mar 13:19  sage -> /home/finotti/src/sage-9.8/venv/share/jupyter/kernels/sagemath/
lrwxrwxrwx    63 finotti finotti 29 May 10:31  sage-10.0 -> /home/finotti/src/sage-10.0/venv/share/jupyter/kernels/sagemath/

Sage 9.8 works as expected, but 10.0's kernel does not work.

Here are some of the error messages:

[I 2023-05-29 10:39:03.537 ServerApp] Kernel started: b57d96c5-8f23-4b05-abbd-abd4aa480f5b
Traceback (most recent call last):
 File "<frozen runpy>", line 198, in _run_module_as_main
 File "<frozen runpy>", line 88, in _run_code
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 3, in <module>
   IPKernelApp.launch_instance(kernel_class=SageKernel)
 File "/home/finotti/src/sage-10.0/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/traitlets/config/application.py", line 981, in launch_instance
   app.initialize(argv)
 File "/home/finotti/src/sage-10.0/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/traitlets/config/application.py", line 110, in inner
   return method(app, *args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/finotti/src/sage-10.0/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/ipykernel/kernelapp.py", line 647, in initialize
   self.init_kernel()
 File "/home/finotti/src/sage-10.0/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/ipykernel/kernelapp.py", line 499, in init_kernel
   kernel = kernel_factory(parent=self, session=self.session,
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 File "/home/finotti/src/sage-10.0/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/traitlets/config/configurable.py", line 551, in instance
   inst = cls(*args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/kernel.py", line 52, in __init__
   SageJupyterCustomizations(self.shell)
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_extension.py", line 445, in __init__
   self.init_environment()
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_extension.py", line 478, in init_environment
   initialize_globals(self.all_globals(), self.shell.user_ns)
                      ^^^^^^^^^^^^^^^^^^
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_extension.py", line 581, in all_globals
   from .ipython_kernel import all_jupyter
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/all_jupyter.py", line 5, in <module>
   from sage.all_cmdline import *
 File "/home/finotti/src/sage-10.0/src/sage/all_cmdline.py", line 17, in <module>
   from sage.all import *
 File "/home/finotti/src/sage-10.0/src/sage/all.py", line 91, in <module>
   from sage.algebras.all   import *
 File "/home/finotti/src/sage-10.0/src/sage/algebras/all.py", line 21, in <module>
   import sage.algebras.catalog as algebras
 File "/home/finotti/src/sage-10.0/src/sage/algebras/catalog.py", line 86, in <module>
   from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra as Quaternion
 File "/home/finotti/src/sage-10.0/src/sage/algebras/quatalg/quaternion_algebra.py", line 73, in <module>
   from . import quaternion_algebra_cython
 File "sage/algebras/quatalg/quaternion_algebra_cython.pyx", line 1, in init sage.algebras.quatalg.quaternion_algebra_cython
   # distutils: language = c++
 File "sage/matrix/matrix_integer_dense.pyx", line 1, in init sage.matrix.matrix_integer_dense
   # -*- coding: utf-8 -*-
ImportError: /home/finotti/src/sage-10.0/src/sage/matrix/matrix_modn_dense_float.cpython-311-x86_64-linux-gnu.so: undefined symbol: _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char
_traitsIcESaIcEEEB5cxx11Ev

Any ideas on what is wrong?

Nils Bruin

unread,
May 29, 2023, 5:11:03 PM5/29/23
to sage-support
On Monday, 29 May 2023 at 07:39:33 UTC-7 Luis Finotti wrote:
 
ImportError: /home/finotti/src/sage-10.0/src/sage/matrix/matrix_modn_dense_float.cpython-311-x86_64-linux-gnu.so: undefined symbol: _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char
_traitsIcESaIcEEEB5cxx11Ev

Any ideas on what is wrong?
That looks like a linking error. Probably it's picking up a library from a different sage install. Did you check that sage-10.0 runs fine by itself? Did you check that sage-10.0 runs fine with its "own" notebook, using "sage --notebook"?

If those do work then I expect that the kernel you point jupyterlab to ends up starting sage with at least part of the environment correct for sage-10.0 (the file you get the error in does lie in sage-10.0) but probably not quite with the right venv set up.
 

Luis Finotti

unread,
May 29, 2023, 5:51:27 PM5/29/23
to sage-support
On Monday, May 29, 2023 at 1:11:03 PM UTC-4 Nils Bruin wrote:

That looks like a linking error. Probably it's picking up a library from a different sage install. Did you check that sage-10.0 runs fine by itself? Did you check that sage-10.0 runs fine with its "own" notebook, using "sage --notebook"?

The answer is yes to both questions.
 
If those do work then I expect that the kernel you point jupyterlab to ends up starting sage with at least part of the environment correct for sage-10.0 (the file you get the error in does lie in sage-10.0) but probably not quite with the right venv set up.

Any ideas on how to fix it?  Is it just me, or a bug with version 10.0?  I followed the same steps I've always followed: https://doc.sagemath.org/html/en/installation/launching.html#setting-up-sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or-jupyterlab-installation

I have the same problem in three different installations (from source), all in Debian Sid.  If I remember well, one of them has only Sage 10.0 installed.
 

Nils Bruin

unread,
May 30, 2023, 12:06:46 AM5/30/23
to sage-support
On Monday, 29 May 2023 at 10:51:27 UTC-7 Luis Finotti wrote:
Any ideas on how to fix it?  Is it just me, or a bug with version 10.0?  I followed the same steps I've always followed: https://doc.sagemath.org/html/en/installation/launching.html#setting-up-sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or-jupyterlab-installation
I guess, to rule out that it's not something weird with jupyterlab, you'd want to try "jupyter notebook" as well and see if the kernel misbehaves then as well (but it would be really weird if it didn't because lab and notebook will be starting their kernels in exactly the same way)

the problem is this symbol:
_ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char
so perhaps if the problem is sage 10.0-specific: did Givaro get upgraded in 10.0? Perhaps you're picking up a different/old Givaro when starting the kernel whereas starting sage "properly" manages to find a givaro built by/for sage 10.0?

You can check:
$HOME/.local/share/jupyter/kernels/sagemath/kernel.json

what command is used to start sage. You could check if that command (bare) works and if it works if you execute "<command> --python"
and then "from sage.all import *"

It could be that the sage script itself got changed and somehow doesn't set the environment as it needs to be to resolve the givaro library properly.

I'm sorry, I don't really have a ready-made solution for you. Hopefully this helps in finding what's wrong and/or may jog someone else into responding.

Luis Finotti

unread,
May 30, 2023, 2:14:30 AM5/30/23
to sage-support
Firstly, thank you very much for your help, Nils!  I greatly appreciate it!

On Monday, May 29, 2023 at 8:06:46 PM UTC-4 Nils Bruin wrote:
On Monday, 29 May 2023 at 10:51:27 UTC-7 Luis Finotti wrote:
Any ideas on how to fix it?  Is it just me, or a bug with version 10.0?  I followed the same steps I've always followed: https://doc.sagemath.org/html/en/installation/launching.html#setting-up-sagemath-as-a-jupyter-kernel-in-an-existing-jupyter-notebook-or-jupyterlab-installation
I guess, to rule out that it's not something weird with jupyterlab, you'd want to try "jupyter notebook" as well and see if the kernel misbehaves then as well (but it would be really weird if it didn't because lab and notebook will be starting their kernels in exactly the same way)

The jupyter notebook had the same problem...
 
the problem is this symbol:
_ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char
so perhaps if the problem is sage 10.0-specific: did Givaro get upgraded in 10.0? Perhaps you're picking up a different/old Givaro when starting the kernel whereas starting sage "properly" manages to find a givaro built by/for sage 10.0?

I am not sure.  I will try to find out.
 
You can check:
$HOME/.local/share/jupyter/kernels/sagemath/kernel.json

what command is used to start sage. You could check if that command (bare) works and if it works if you execute "<command> --python"
and then "from sage.all import *"

That worked fine, no errors and a few commands worked as expected.
 
It could be that the sage script itself got changed and somehow doesn't set the environment as it needs to be to resolve the givaro library properly.

I'm sorry, I don't really have a ready-made solution for you. Hopefully this helps in finding what's wrong and/or may jog someone else into responding.

Again, I really appreciate you taking the time to help!

Jan Groenewald

unread,
May 30, 2023, 6:21:22 AM5/30/23
to sage-s...@googlegroups.com
Hi

Also see
... in case it is related.

Regards,
Jan



--
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/3adc3135-e4ab-4fa1-ab26-a8d6417155d9n%40googlegroups.com.

Luis Finotti

unread,
May 30, 2023, 1:09:23 PM5/30/23
to sage-support
Thanks for the reply!

On Tuesday, May 30, 2023 at 2:21:22 AM UTC-4 Jan Groenewald wrote:

I looked at it, but I cannot tell if it is really the same issue, or how I could check.

I've seen this comment, by Volker Braun:

IMHO we just shouldn't use the system version then, but building Sage with -D_GLIBCXX_USE_CXX11_ABI=0 should allow you to link with old-style abi libraries.

The default value of _GLIBCXX_USE_CXX11_ABI can be changed by the distro, which is probably what accounts for the differences seen in this thread.

How does one do that, i.e., compile Sage with -D_GLIBCXX_USE_CXX11_ABI=0?  Or are is there anything else I can try?

Nils Bruin

unread,
May 30, 2023, 4:48:26 PM5/30/23
to sage-support
On Tuesday, 30 May 2023 at 06:09:23 UTC-7 Luis Finotti wrote:

I looked at it, but I cannot tell if it is really the same issue, or how I could check.

well ... it looks like the symbol that is found undefined is indeed of the type mentioned there. So that would suggest that indeed a system givaro is picked up while sage is apparently compiled with a "too advanced" c++ ABI for that library. However, you're not getting errors when you just run sage-10.0, so it would seem there is a givaro library that can satisfy the needs (it probably built its own givaro)

So in your case there seems to be something about the environment in which jupyter starts sage that confuses the library resolution process. I imagine it could be something where juoyter runs using a python that has its own venv and that the initialization of sage (which should set up its venv) somehow misses overriding something or erroneously inherits something from the jupyter venv.

In that case I would expect this issue was basically always present, but has only recently become relevant because now the system givaro doesn't cut it any more.

Jan Groenewald

unread,
May 31, 2023, 7:37:30 PM5/31/23
to sage-s...@googlegroups.com
Hi

suggests trying clang 14 for compiling sage or waiting for givaro compiled with clang 15.

(or just try rebuild the deb for givaro with clang15 https://raphaelhertzog.com/2010/12/15/howto-to-rebuild-debian-packages/)

Regards,
Jan

--
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.

Isuru Fernando

unread,
May 31, 2023, 7:46:14 PM5/31/23
to sage-s...@googlegroups.com
That's a different issue than this.

Isuru

Isuru Fernando

unread,
May 31, 2023, 8:24:11 PM5/31/23
to sage-support
Try running JupyterLab in a shell with `export LD_DEBUG=libs` and import sage with that jupyterlab instance.
That should tell you where givaro is loaded from.

Isuru

Luis Finotti

unread,
May 31, 2023, 8:46:51 PM5/31/23
to sage-support
Hello,

Thanks for the help!

On Wednesday, May 31, 2023 at 4:24:11 PM UTC-4 Isuru Fernando wrote:
Try running JupyterLab in a shell with `export LD_DEBUG=libs` and import sage with that jupyterlab instance.
That should tell you where givaro is loaded from.

Isuru

The output is very long, but maybe this is what you mean:

    916747: find library=libgivaro.so.9 [0]; searching
    916747:  search path=/usr/lib/R/lib (LD_LIBRARY_PATH)
    916747:   trying file=/usr/lib/R/lib/libgivaro.so.9
    916747:  search path=/usr/lib/x86_64-linux-gnu (system search path)
    916747:   trying file=/usr/lib/x86_64-linux-gnu/libgivaro.so.9
    916747:
    916747: find library=libgmpxx.so.4 [0]; searching
    916747:  search path=/usr/lib/R/lib (LD_LIBRARY_PATH)
    916747:   trying file=/usr/lib/R/lib/libgmpxx.so.4
    916747:  search path=/usr/lib/x86_64-linux-gnu (system search path)
    916747:   trying file=/usr/lib/x86_64-linux-gnu/libgmpxx.so.4
    916747:
    916747:
    916747: calling init: /usr/lib/x86_64-linux-gnu/libgmpxx.so.4
    916747:
    916747:
    916747: calling init: /usr/lib/x86_64-linux-gnu/libgivaro.so.9
    916747:
    916747:
    916747: calling init: /home/finotti/src/sage-test/sage-10.0/src/sage/rings/finite_rings/element_givaro.cpython-311-x86_64-linux-gnu.so

Later we see the error

    916747: /home/finotti/src/sage-test/sage-10.0/src/sage/matrix/matrix_modn_dense_float.cpython-311-x86_64-linux-gnu.so: error: symbol lookup error: undefined symbol: _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEB5cxx11Ev (fatal)

Any ideas?

Isuru Fernando

unread,
May 31, 2023, 9:29:25 PM5/31/23
to sage-s...@googlegroups.com
Does `import sage.all` in a sage shell work?

Isuru

--
You received this message because you are subscribed to a topic in the Google Groups "sage-support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/we-BvSt6WRk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/d6430e5a-929e-4662-8852-0bb9ff6f948an%40googlegroups.com.

Luis Finotti

unread,
May 31, 2023, 10:02:05 PM5/31/23
to sage-support
On Wednesday, May 31, 2023 at 5:29:25 PM UTC-4 Isuru Fernando wrote:
Does `import sage.all` in a sage shell work?

In a regular sage shell (from the command line, not in Jupyter Lab)?  Yes, no errors (or output).

Isuru Fernando

unread,
May 31, 2023, 10:10:42 PM5/31/23
to sage-s...@googlegroups.com
Which givaro library is loaded when you do `export LD_DEBUG=libs` and run sage from the command line?

Isuru

--
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/0c189ebc-0b29-4d1e-b367-4494bebd5e49n%40googlegroups.com.

Luis Finotti

unread,
May 31, 2023, 10:23:33 PM5/31/23
to sage-support
On Wednesday, May 31, 2023 at 6:10:42 PM UTC-4 Isuru Fernando wrote:
Which givaro library is loaded when you do `export LD_DEBUG=libs` and run sage from the command line?


I get:

   1028008:     find library=libgivaro.so.9 [0]; searching
   1028008:      search path=/home/finotti/src/sage-10.0/local/lib              (RUNPATH from file /home/finotti/src/sage-10.0/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so)
   1028008:       trying file=/home/finotti/src/sage-10.0/local/lib/libgivaro.so.9
   1028008:
   1028008:     find library=libgmpxx.so.4 [0]; searching
   1028008:      search path=/home/finotti/src/sage-10.0/local/lib              (RUNPATH from file /home/finotti/src/sage-10.0/local/var/lib/sage/venv-python3.11/lib/python3.11/site-packages/cysignals/signals.cpython-311-x86_64-linux-gnu.so)
   1028008:       trying file=/home/finotti/src/sage-10.0/local/lib/libgmpxx.so.4
   1028008:      search cache=/etc/ld.so.cache
   1028008:       trying file=/lib/x86_64-linux-gnu/libgmpxx.so.4
   1028008:
   1028008:
   1028008:     calling init: /lib/x86_64-linux-gnu/libgmpxx.so.4
   1028008:
   1028008:
   1028008:     calling init: /home/finotti/src/sage-10.0/local/lib/libgivaro.so.9
   1028008:
   1028008:
   1028008:     calling init: /home/finotti/src/sage-10.0/src/sage/rings/finite_rings/element_givaro.cpython-311-x86_64-linux-gnu.so
[snip]
   1028008:     calling fini: /home/finotti/src/sage-10.0/src/sage/rings/finite_rings/element_givaro.cpython-311-x86_64-linux-gnu.so [0
   1028008:
   1028008:
   1028008:     calling fini: /home/finotti/src/sage-10.0/local/lib/libgivaro.so.9 [0]

Isuru Fernando

unread,
May 31, 2023, 10:29:49 PM5/31/23
to sage-s...@googlegroups.com
Try adding

   import sage.all

to the top of /home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py

Isuru

--
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.

Luis Finotti

unread,
Jun 1, 2023, 12:05:01 AM6/1/23
to sage-support
Thanks again for the help!  It is really appreciated!

Unfortunately, it did not work:

[I 2023-05-31 20:01:40.186 ServerApp] Kernel started: b7d122c3-383b-463b-b196-193ba26373aa
\0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this
validation.
-[I 2023-05-31 20:01:41.577 ServerApp] Connecting to kernel b7d122c3-383b-463b-b196-193ba26
373aa.
[I 2023-05-31 20:01:41.580 ServerApp] Connecting to kernel b7d122c3-383b-463b-b196-193ba263
73aa.
[I 2023-05-31 20:01:41.595 ServerApp] Connecting to kernel b7d122c3-383b-463b-b196-193ba263
73aa.
\[IPKernelApp] WARNING | Unknown message type: 'comm_open'
[IPKernelApp] WARNING | Unknown message type: 'comm_msg'
[W 2023-05-31 20:01:41.657 ServerApp] Got events for closed stream <zmq.eventloop.zmqstream
.ZMQStream object at 0x7f8f0c2cf990>
[I 2023-05-31 20:01:50.449 ServerApp] Creating new notebook in
[I 2023-05-31 20:01:50.844 ServerApp] Kernel started: 2d1683ba-e9f5-4158-b989-8ff8bfbc8f51
Traceback (most recent call last):
 File "<frozen runpy>", line 189, in _run_module_as_main
 File "<frozen runpy>", line 148, in _get_module_details
 File "<frozen runpy>", line 159, in _get_module_details
 File "<frozen importlib._bootstrap_external>", line 1074, in get_code
 File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
 File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent
[I 2023-05-31 20:01:53.834 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (1/5),
new random ports
Traceback (most recent call last):
 File "<frozen runpy>", line 189, in _run_module_as_main
 File "<frozen runpy>", line 148, in _get_module_details
 File "<frozen runpy>", line 159, in _get_module_details
 File "<frozen importlib._bootstrap_external>", line 1074, in get_code
 File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
 File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent
[I 2023-05-31 20:01:56.846 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (2/5),
new random ports
Traceback (most recent call last):
 File "<frozen runpy>", line 189, in _run_module_as_main
 File "<frozen runpy>", line 148, in _get_module_details
 File "<frozen runpy>", line 159, in _get_module_details
 File "<frozen importlib._bootstrap_external>", line 1074, in get_code
 File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
 File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent
[I 2023-05-31 20:01:59.861 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (3/5),
new random ports
Traceback (most recent call last):
 File "<frozen runpy>", line 189, in _run_module_as_main
 File "<frozen runpy>", line 148, in _get_module_details
 File "<frozen runpy>", line 159, in _get_module_details
 File "<frozen importlib._bootstrap_external>", line 1074, in get_code
 File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
 File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent
[I 2023-05-31 20:02:02.875 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (4/5),
new random ports
Traceback (most recent call last):
 File "<frozen runpy>", line 189, in _run_module_as_main
 File "<frozen runpy>", line 148, in _get_module_details
 File "<frozen runpy>", line 159, in _get_module_details
 File "<frozen importlib._bootstrap_external>", line 1074, in get_code
 File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
 File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent
[I 2023-05-31 20:02:05.888 ServerApp] AsyncIOLoopKernelRestarter: restarting kernel (5/5),
new random ports
Traceback (most recent call last):
 File "<frozen runpy>", line 189, in _run_module_as_main
 File "<frozen runpy>", line 148, in _get_module_details
 File "<frozen runpy>", line 159, in _get_module_details
 File "<frozen importlib._bootstrap_external>", line 1074, in get_code
 File "<frozen importlib._bootstrap_external>", line 1004, in source_to_code
 File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent
[W 2023-05-31 20:02:08.901 ServerApp] AsyncIOLoopKernelRestarter: restart failed
[W 2023-05-31 20:02:08.901 ServerApp] Kernel 2d1683ba-e9f5-4158-b989-8ff8bfbc8f51 died, rem
oving from map.
[W 2023-05-31 20:02:50.881 ServerApp] Timeout waiting for kernel_info reply from 2d1683ba-e
9f5-4158-b989-8ff8bfbc8f51
[E 2023-05-31 20:02:50.881 ServerApp] Uncaught exception GET /api/kernels/2d1683ba-e9f5-415
8-b989-8ff8bfbc8f51/channels?session_id=e7e7ebeb-a613-4c4c-9e1a-eb0e366db3d4 (::1)
   HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kerne
ls/2d1683ba-e9f5-4158-b989-8ff8bfbc8f51/channels?session_id=e7e7ebeb-a613-4c4c-9e1a-eb0e366
db3d4', version='HTTP/1.1', remote_ip='::1')
   Traceback (most recent call last):
     File "/usr/lib/python3/dist-packages/tornado/web.py", line 1713, in _execute
       result = await result
                ^^^^^^^^^^^^
     File "/home/finotti/.local/lib/python3.11/site-packages/jupyter_server/services/kerne
ls/websocket.py", line 67, in get
       await super().get(kernel_id=kernel_id)
     File "/usr/lib/python3/dist-packages/tornado/websocket.py", line 277, in get
       await self.ws_connection.accept_connection(self)
     File "/usr/lib/python3/dist-packages/tornado/websocket.py", line 867, in accept_conne
ction
       await self._accept_connection(handler)
     File "/usr/lib/python3/dist-packages/tornado/websocket.py", line 907, in _accept_conn
ection
       self.selected_subprotocol = handler.select_subprotocol(subprotocols)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/home/finotti/.local/lib/python3.11/site-packages/jupyter_server/services/kerne
ls/websocket.py", line 86, in select_subprotocol
       preferred_protocol = self.connection.kernel_ws_protocol
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   AttributeError: 'NoneType' object has no attribute 'kernel_ws_protocol'
[E 2023-05-31 20:02:50.889 ServerApp] {
     "Host": "localhost:8888",
     "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/113.0.0.0 Safari/537.36"
   }
[E 2023-05-31 20:02:50.890 ServerApp] 500 GET /api/kernels/2d1683ba-e9f5-4158-b989-8ff8bfbc
8f51/channels?session_id=e7e7ebeb-a613-4c4c-9e1a-eb0e366db3d4 (1d8eff8bf21445009a41400a789f
dd1f@::1) 60013.83ms referer=None
[W 2023-05-31 20:02:51.190 ServerApp] Timeout waiting for kernel_info reply from 2d1683ba-e
9f5-4158-b989-8ff8bfbc8f51
[E 2023-05-31 20:02:51.190 ServerApp] Uncaught exception GET /api/kernels/2d1683ba-e9f5-415
8-b989-8ff8bfbc8f51/channels?session_id=ef28bbb4-915d-49a2-9007-f81e28396ccb (127.0.0.1)
   HTTPServerRequest(protocol='http', host='localhost:8888', method='GET', uri='/api/kerne
ls/2d1683ba-e9f5-4158-b989-8ff8bfbc8f51/channels?session_id=ef28bbb4-915d-49a2-9007-f81e283
96ccb', version='HTTP/1.1', remote_ip='127.0.0.1')
   Traceback (most recent call last):
     File "/usr/lib/python3/dist-packages/tornado/web.py", line 1713, in _execute
       result = await result
                ^^^^^^^^^^^^
     File "/home/finotti/.local/lib/python3.11/site-packages/jupyter_server/services/kerne
ls/websocket.py", line 67, in get
       await super().get(kernel_id=kernel_id)
     File "/usr/lib/python3/dist-packages/tornado/websocket.py", line 277, in get
       await self.ws_connection.accept_connection(self)
     File "/usr/lib/python3/dist-packages/tornado/websocket.py", line 867, in accept_conne
ction
       await self._accept_connection(handler)
     File "/usr/lib/python3/dist-packages/tornado/websocket.py", line 907, in _accept_conn
ection
       self.selected_subprotocol = handler.select_subprotocol(subprotocols)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     File "/home/finotti/.local/lib/python3.11/site-packages/jupyter_server/services/kerne
ls/websocket.py", line 86, in select_subprotocol
       preferred_protocol = self.connection.kernel_ws_protocol
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   AttributeError: 'NoneType' object has no attribute 'kernel_ws_protocol'
[E 2023-05-31 20:02:51.191 ServerApp] {
     "Host": "localhost:8888",
     "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/113.0.0.0 Safari/537.36"
   }
[E 2023-05-31 20:02:51.191 ServerApp] 500 GET /api/kernels/2d1683ba-e9f5-4158-b989-8ff8bfbc
8f51/channels?session_id=ef28bbb4-915d-49a2-9007-f81e28396ccb (1d8eff8bf21445009a41400a789f
dd...@127.0.0.1) 60004.10ms referer=None

Isuru Fernando

unread,
Jun 1, 2023, 12:07:23 AM6/1/23
to sage-s...@googlegroups.com
Following seems to indicate that there were some space before `import sage.all`

Isuru

 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent 

Luis Finotti

unread,
Jun 1, 2023, 12:15:01 AM6/1/23
to sage-support
Ah, sorry!  I've fixed,  but it is still not working:

[I 2023-05-31 20:13:22.480 ServerApp] Connecting to kernel 28308c3f-6fa3-4b63-91b6-cc5e1278
2d4d.
[I 2023-05-31 20:13:22.500 ServerApp] Connecting to kernel 28308c3f-6fa3-4b63-91b6-cc5e1278
2d4d.
[IPKernelApp] WARNING | Unknown message type: 'comm_open'
[I 2023-05-31 20:13:22.526 ServerApp] Connecting to kernel 28308c3f-6fa3-4b63-91b6-cc5e1278
2d4d.
[IPKernelApp] WARNING | Unknown message type: 'comm_msg'
[W 2023-05-31 20:13:22.551 ServerApp] Got events for closed stream <zmq.eventloop.zmqstream
.ZMQStream object at 0x7fd0ee6569d0>
Traceback (most recent call last):
 File "<frozen runpy>", line 198, in _run_module_as_main
 File "<frozen runpy>", line 88, in _run_code
 File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1, in <
module>
   import sage.all
 File "/home/finotti/src/sage-10.0/src/sage/all.py", line 91, in <module>
   from sage.algebras.all   import *
 File "/home/finotti/src/sage-10.0/src/sage/algebras/all.py", line 21, in <module>
   import sage.algebras.catalog as algebras
 File "/home/finotti/src/sage-10.0/src/sage/algebras/catalog.py", line 86, in <module>
   from sage.algebras.quatalg.quaternion_algebra import QuaternionAlgebra as Quaternion
 File "/home/finotti/src/sage-10.0/src/sage/algebras/quatalg/quaternion_algebra.py", line
73, in <module>
   from . import quaternion_algebra_cython
 File "sage/algebras/quatalg/quaternion_algebra_cython.pyx", line 1, in init sage.algebras
.quatalg.quaternion_algebra_cython
 File "sage/matrix/matrix_integer_dense.pyx", line 1, in init sage.matrix.matrix_integer_d
ense
ImportError: /home/finotti/src/sage-10.0/src/sage/matrix/matrix_modn_dense_float.cpython-31
1-x86_64-linux-gnu.so: undefined symbol: _ZNK6Givaro7IntegercvNSt7__cxx1112basic_stringIcSt
11char_traitsIcESaIcEEEB5cxx11Ev

Isuru Fernando

unread,
Jun 1, 2023, 1:03:15 AM6/1/23
to sage-s...@googlegroups.com
Can you upload the full log with `LD_DEBUG=libs` and jupyterlab somewhere and post a link?

Isuru

--
You received this message because you are subscribed to a topic in the Google Groups "sage-support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sage-support/we-BvSt6WRk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sage-support...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sage-support/d6430e5a-929e-4662-8852-0bb9ff6f948an%40googlegroups.com.

Luis Finotti

unread,
Jun 1, 2023, 1:14:59 AM6/1/23
to sage-support
Here is one with your suggested change: https://web.math.utk.edu/~finotti/misc/jl1.out

Here is one with the original version: https://web.math.utk.edu/~finotti/misc/jl2.out

Again, thanks for your help!

Jan Groenewald

unread,
Jun 1, 2023, 5:30:58 AM6/1/23
to sage-s...@googlegroups.com
Check this:

File "/home/finotti/src/sage-10.0/src/sage/repl/ipython_kernel/__main__.py", line 1
   import sage.all
IndentationError: unexpected indent
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/1d04ffeb-e645-4878-a1f1-dce01c73e41en%40googlegroups.com.

Nils Bruin

unread,
Jun 1, 2023, 8:55:57 AM6/1/23
to sage-support
On Wednesday, 31 May 2023 at 18:14:59 UTC-7 Luis Finotti wrote:
Here is one with your suggested change: https://web.math.utk.edu/~finotti/misc/jl1.out

Here is one with the original version: https://web.math.utk.edu/~finotti/misc/jl2.out

the line:
 
calling init: /usr/lib/x86_64-linux-gnu/libgivaro.so.9

is definitely indicating that you are picking up a system libgivaro.

Perhaps you can check in the same way which libgivaro gets linked when you run sage in a way where you don't get the "undefined symbol" error? If it's a different library then the system library is perhaps the problem.

Luis Finotti

unread,
Jun 1, 2023, 2:29:27 PM6/1/23
to sage-support
On Thursday, June 1, 2023 at 4:55:57 AM UTC-4 Nils Bruin wrote:

the line:
 
calling init: /usr/lib/x86_64-linux-gnu/libgivaro.so.9

is definitely indicating that you are picking up a system libgivaro.

Perhaps you can check in the same way which libgivaro gets linked when you run sage in a way where you don't get the "undefined symbol" error? If it's a different library then the system library is perhaps the problem.

OK, so removing my computer's own libgivaro9 and libgivaro-dev, Jupyter Lab works with no problems, so the problem was definitely the system's library.

I am not sure I will miss them (and other packages that depended on it -- fflas-ffpack libgivaro-dev libgivaro9 liblinbox-dev python3-brial python3-sage), but isn't there a way to force Jupyter to use Sage's one?
 

Nils Bruin

unread,
Jun 1, 2023, 4:46:33 PM6/1/23
to sage-support
On Thursday, 1 June 2023 at 07:29:27 UTC-7 Luis Finotti wrote:

I am not sure I will miss them (and other packages that depended on it -- fflas-ffpack libgivaro-dev libgivaro9 liblinbox-dev python3-brial python3-sage), but isn't there a way to force Jupyter to use Sage's one?
 
I don't think jupyter cares about givaro. However, it sounds like your jupyter sets up some things about the library search path (perhaps an LD_LIBRARY_PATH)? that gets inherited by the sage process that gets subsequently run to start the kernel. The sage script normally seems to set search paths in such a way that it picks the right libgivaro, but when run in the environment created by jupyter apparently it doesn't any more.

That sounds like a bit of a bug to me. You've found a work-around by making sure the only givaro on your system is the one sage built. But really, the way sage sets up its environment shouldn't be derailed by what another jupyter install does prior to it.

The first candidate for causing this is a value for LD_LIBRARY_PATH, so if you could look check

"LD_LIBRARY_PATH" in os.environ

in both your command-line sage and in sage through jupyterlab then you'd know if there's a difference. Generally comparing the contents of os.environ between the two may give you some insight in what might be causing the difference in behaviour.

The whole point of python's "venv" is that you CAN run different programs with conflicting library requirements easily. So you could help if you can pinpoint what is going wrong here -- perhaps it's a misconfiguration on your system but it could also be a bug/oversight in how python's venvs are managed.

Dima Pasechnik

unread,
Jun 1, 2023, 4:52:46 PM6/1/23
to sage-support
Sounds like RPATH has to used somewhere to make sure the correct dynamic library is used.



--
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/032ca71d-5f67-44db-89dc-ed0423201135n%40googlegroups.com.

Luis Finotti

unread,
Jun 1, 2023, 5:54:06 PM6/1/23
to sage-support
On Thursday, June 1, 2023 at 12:46:33 PM UTC-4 Nils Bruin wrote:
 
I don't think jupyter cares about givaro. However, it sounds like your jupyter sets up some things about the library search path (perhaps an LD_LIBRARY_PATH)? that gets inherited by the sage process that gets subsequently run to start the kernel. The sage script normally seems to set search paths in such a way that it picks the right libgivaro, but when run in the environment created by jupyter apparently it doesn't any more.

That sounds like a bit of a bug to me. You've found a work-around by making sure the only givaro on your system is the one sage built. But really, the way sage sets up its environment shouldn't be derailed by what another jupyter install does prior to it.

The first candidate for causing this is a value for LD_LIBRARY_PATH, so if you could look check

"LD_LIBRARY_PATH" in os.environ

in both your command-line sage and in sage through jupyterlab then you'd know if there's a difference. Generally comparing the contents of os.environ between the two may give you some insight in what might be causing the difference in behaviour.

The whole point of python's "venv" is that you CAN run different programs with conflicting library requirements easily. So you could help if you can pinpoint what is going wrong here -- perhaps it's a misconfiguration on your system but it could also be a bug/oversight in how python's venvs are managed.

Thanks again for your reply.

In the sage shell, I have no LD_LIBRARY_PATH in os.environ.  I get only (with PATH in the key):

PKG_CONFIG_PATH
QTWEBENGINE_DICTIONARIES_PATH
INFOPATH
LIBRARY_PATH
SAGE_ORIG_PATH_SET
PATH
SAGE_ORIG_PATH
CPATH

Under Jupyter, with givaro removed, I get:

PKG_CONFIG_PATH
QTWEBENGINE_DICTIONARIES_PATH
INFOPATH
LIBRARY_PATH
SAGE_ORIG_PATH_SET
LD_LIBRARY_PATH
PATH
SAGE_ORIG_PATH
CPATH

and LD_LIBRARY_PATH is '/home/finotti/src/sage-10.0/local/lib'

Luis Finotti

unread,
Jun 1, 2023, 7:05:39 PM6/1/23
to sage-support
Interestingly enough, I have another computer, also running Debian Sid, but a much older installation, in which Sage-10.0 *does* work in Jupyter lab.  In this one, when I look at os.eviron, I also do not have LD_LIRBRARY_PATH...

Jan Groenewald

unread,
Jun 1, 2023, 7:13:18 PM6/1/23
to sage-s...@googlegroups.com
On Thu, 1 Jun 2023 at 21:05, Luis Finotti <luis.f...@gmail.com> wrote:
Interestingly enough, I have another computer, also running Debian Sid, but a much older installation, in which Sage-10.0 *does* work in Jupyter lab.  In this one, when I look at os.eviron, I also do not have LD_LIRBRARY_PATH...

And which version of system givaro installed?

Regards,
Jan



 
--
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/4b7ba96f-d2a4-46d1-8711-8d67c0740985n%40googlegroups.com.

Luis Finotti

unread,
Jun 1, 2023, 7:20:14 PM6/1/23
to sage-support
On Thursday, June 1, 2023 at 3:13:18 PM UTC-4 Jan Groenewald wrote:
On Thu, 1 Jun 2023 at 21:05, Luis Finotti <luis.f...@gmail.com> wrote:
Interestingly enough, I have another computer, also running Debian Sid, but a much older installation, in which Sage-10.0 *does* work in Jupyter lab.  In this one, when I look at os.eviron, I also do not have LD_LIRBRARY_PATH...

And which version of system givaro installed?

The same ones as the other system (before removing):

libgivaro-dev:
  Installed: 4.2.0-3
  Candidate: 4.2.0-3
  Version table:
 *** 4.2.0-3 500
        500 http://debian-archive.trafficmanager.net/debian unstable/main amd64 Packages
        100 /var/lib/dpkg/status
libgivaro9:
  Installed: 4.2.0-3
  Candidate: 4.2.0-3
  Version table:
 *** 4.2.0-3 500
        500 http://debian-archive.trafficmanager.net/debian unstable/main amd64 Packages
 
Reply all
Reply to author
Forward
0 new messages