WSL2 installation sage-ipython can't find packages

88 views
Skip to first unread message

Jeremy Kun

unread,
Oct 13, 2022, 1:17:31 AM10/13/22
to sage-support
Hi all,

I'm trying to run sage on WSL2 (Ubuntu focal 20.04.5 LTS), and after a fresh install (sadly only version 9.0), running `sage` gives the following error.

ModuleNotFoundError: No module named 'sage.cpython.string'

I happen to know that the packages are installed in /usr/lib/python3/dist-packages/, and sage/cpython/string.pyx is in there.

What's particularly strange to me is that sage can find `sage.misc.banner` (which is in the same dist-packages location). Meanwhile, I can run `sage -python` and inspect `sys.path` manually (it has the right dist-packages path in it), but importing sage.all in that context fails with "ModuleNotFoundError: No module named 'cysignals.signals'" and similar with other imports.

➜  ~ ls -l /usr/lib/python3/dist-packages/sage
.rw-r--r-- 2.3k root  1 Jan  2020 __init__.py
drwxr-xr-x    - root 12 Oct 20:34 __pycache__
drwxr-xr-x    - root 12 Oct 20:34 algebras
.rw-r--r--  12k root  8 Feb  2020 all.py
<...snipped...>
➜  ~ sage -python
Python 3.9.14 (main, Sep  7 2022, 23:43:29)
[GCC 9.4.0] on linux
>>> import sys
>>> print(sys.path)
['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/home/j2kun/.local/lib/python3.9/site-packages', '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages']
>>> import sage.all
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/sage/all.py", line 77, in <module>
    from cysignals.signals import (AlarmInterrupt, SignalError,
  File "/usr/lib/python3/dist-packages/cysignals/__init__.py", line 1, in <module>
    from .signals import AlarmInterrupt, SignalError, init_cysignals  # noqa
ModuleNotFoundError: No module named 'cysignals.signals' (jkun's note: it's there in
 /usr/lib/python3/dist-packages/cysignals/)

I understand the recommendation is to use conda or build from source to get a version > 9.2, but is there a quick fix I can do to link the sage-python to these libraries? Maybe an existing trac issue I can read through workarounds? The reason I ask is because I'm working on a library that uses sage and it's a bit of a pain to fire up docker (and worse, the sagemath docker image had known issues (only just now seeing that a new docker image got pushed; still, working in docker is a bit inconvenient))

Any ideas? Further steps for investigation?

Matthias Koeppe

unread,
Oct 14, 2022, 1:25:10 PM10/14/22
to sage-support
Report Ubuntu packaging bugs to Ubuntu

Dima Pasechnik

unread,
Oct 14, 2022, 1:56:05 PM10/14/22
to sage-support
I frankly don't understand Debian/Ubuntu packaging of SageMath. E.g. Sage 9.0 was never tested with Python 3.9, and their current version of cysignals. 

Surely they are trying to backport our changes, but this is quite error-prone.

Please use conda, or build from source, or use  Linux distro with much more up to date Sage, e.g.
archlinux or Gentoo.


HTH
Dima




--
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/1545b076-f5f7-4a54-9959-1940e53e4b8dn%40googlegroups.com.

F Lengyel

unread,
Oct 16, 2022, 12:13:06 AM10/16/22
to sage-support
This pertains to installation of sage-9.7.tar.gz under WSL2. I've found it necessary to run

cp -r $HOME/sage/sage-9.7/src/sage/ext_data/        $HOME/sage/local/lib/sage

in order for various packages to pick up code in ext_data. I'm compiling from source. I prefer
to configure sage to compile as much as possible and to rely on ubuntu/debian packages
as little as possible.

Matthias Koeppe

unread,
Oct 17, 2022, 5:00:56 PM10/17/22
to sage-support
Details please - what is broken

Henri Girard

unread,
Oct 17, 2022, 5:11:42 PM10/17/22
to sage-s...@googlegroups.com

wsl2 in ubuntu  22.04 has 9.5.4.1 sagemath

F Lengyel

unread,
Oct 20, 2022, 11:02:02 AM10/20/22
to sage-support
On Monday, October 17, 2022 at 5:00:56 PM UTC-4 Matthias Koeppe wrote:
Details please - what is broken


Apologies -- the related error occurs in Ubuntu 20.04 compiling sage-9.7 and
on the raspberry pi running Raspbian GNU/Linux 11 also compiling sage-9.7, and 
after a successful build.

The configure command is source from $HOME/sage/sage-9.7 as follows.

export PATH=${HOME}/sage/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:
export SAGE_HOME=${HOME}/sage/sage-9.7
export SAGE_LOCAL=${HOME}/sage/local
#export SAGE_BUILD_DIR="$HOME/tmp/sage"
export MAKE="make -j4"


./configure --prefix=$SAGE_LOCAL  --without-system-python3  \
            --with-system-givaro=no --enable-d3js=yes --enable-gap3 --enable-gap_jupyter \
            --enable-pari_galpol --enable-pari_jupyter --enable-pysingular --enable-python_igraph \
            --enable-singular_jupyter --enable-lidia --enable-coxeter3 --enable-lie \
            --enable-r_jupyter --enable-p_group_cohomology

A make build succeeds.


However this command fails:
sage -i jupyterlab_widgets


[sagelib-9.7]     Installed /home/pi/sage/sage-9.7/src
[sagelib-9.7]     error: [Errno 2] No such file or directory: '/home/pi/sage/local/lib/sage/ext_data/notebook-ipython'
[sagelib-9.7]     error: subprocess-exited-with-error

The error is:

make: *** [Makefile:40: all-build] Error 1
Installing /home/pi/sage/local/lib/python3.10/site-packages/widgetsnbextension/static -> jupyter-js-widgets
Up to date: /home/pi/sage/local/share/jupyter/nbextensions/jupyter-js-widgets/extension.js.map
Up to date: /home/pi/sage/local/share/jupyter/nbextensions/jupyter-js-widgets/extension.js

A related error occurs when attempting to run show3d() in sage-9.7. This led to the following error.

```python
    /home/flengyel/sage/sage-9.7/src/sage/repl/rich_output/display_manager.py:610: RichReprWarning: Exception in _rich_repr_ while displaying object: [Errno 2] No such file or directory: '/home/flengyel/sage/local/lib/sage/ext_data/threejs/threejs-version.txt'
      warnings.warn(
```
 
I mention this because the fix in both cases is to copy the missing files to $HOME/sage/local/lib/sage/ext_data

-FL

F Lengyel

unread,
Oct 20, 2022, 10:01:44 PM10/20/22
to sage-support
I'd like to point out that after a  mkdir -p $HOME/sage/local/lib/sage/ext_data
and a recursive copy of the contents of $HOME/sage/sage-9.7/src/sage/ext_data  
to   $HOME/sage/local/lib/sage/ext_data

in commands:

cd $HOME/sage/sage-9.7/src/sage/ext_data
cp -r .  $HOME/sage/local/lib/sage/ext_data

The following commands completed successfully (output below)

sage -i jupyterlab_widgets
jupyter nbextension install --py widgetsnbextension --sys-prefix
jupyter nbextension enable widgetsnbextension --py --sys-prefix

The first command, sage -i jupyterlab_widgets, ended with errors as previously shown.
It appears that dependencies on ext_data are not handled properly. 

[sagelib-9.7]     Installed /home/pi/sage/sage-9.7/src
[sagelib-9.7] Successfully installed sagemath-standard-9.7
[sagelib-9.7]
[sagelib-9.7] real      1m38.162s
[sagelib-9.7] user      1m12.172s
[sagelib-9.7] sys       0m10.998s
make[1]: Leaving directory '/home/pi/sage/sage-9.7/build/make'

real    2m8.475s
user    1m41.280s
sys     0m15.189s
Sage build/upgrade complete!

Installing /home/pi/sage/local/lib/python3.10/site-packages/widgetsnbextension/static -> jupyter-js-widgets
Up to date: /home/pi/sage/local/share/jupyter/nbextensions/jupyter-js-widgets/extension.js.map
Up to date: /home/pi/sage/local/share/jupyter/nbextensions/jupyter-js-widgets/extension.js
- Validating: OK

    To initialize this nbextension in the browser every time the notebook (or other app) loads:

          jupyter nbextension enable widgetsnbextension --py --sys-prefix

Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: OK

-FL
Reply all
Reply to author
Forward
0 new messages