Needed to downgrade markupsafe from 2.1.1 to 2.0.1 to let sage -n jupyterlab work

194 views
Skip to first unread message

Sébastien Labbé

unread,
Apr 7, 2022, 7:50:37 AM4/7/22
to sage-devel
On the computer of a Student (I think Ubuntu 20.04) with 9.6.beta7 installing jupyterlab fails with the error "ImportError: cannot import name 'soft_unicode' from 'markupsafe' ".
Googling this error, we found this link: https://github.com/aws/aws-sam-cli/issues/3661
suggesting to downgrade markupsafe from 2.1.1 to 2.0.1.
After doing that, sage -n jupyterlab worked.
Should build/pkgs/markupsafe/install-requires.txt be adapted?

$ cat build/pkgs/markupsafe/install-requires.txt
markupsafe >=1.1.0

Traceback of the error is here:

[...]
[sagelib-9.6.beta7] Traceback (most recent call last):
[sagelib-9.6.beta7]   File "setup.py", line 101, in <module>
[sagelib-9.6.beta7]     code = setup(
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
[sagelib-9.6.beta7]     return distutils.core.setup(**attrs)
[sagelib-9.6.beta7]   File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
[sagelib-9.6.beta7]     dist.run_commands()
[sagelib-9.6.beta7]   File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
[sagelib-9.6.beta7]     self.run_command(cmd)
[sagelib-9.6.beta7]   File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
[sagelib-9.6.beta7]     cmd_obj.run()
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage_setup/command/sage_build.py", line 36, in run
[sagelib-9.6.beta7]     self.run_autogen()
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage_setup/command/sage_build.py", line 18, in run_autogen
[sagelib-9.6.beta7]     from sage_setup.autogen import autogen_all
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage_setup/autogen/__init__.py", line 2, in <module>
[sagelib-9.6.beta7]     from . import interpreters
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage_setup/autogen/interpreters/__init__.py", line 118, in <module>
[sagelib-9.6.beta7]     from .generator import InterpreterGenerator, AUTOGEN_WARN
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage_setup/autogen/interpreters/generator.py", line 19, in <module>
[sagelib-9.6.beta7]     from .memory import string_of_addr
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage_setup/autogen/interpreters/memory.py", line 16, in <module>
[sagelib-9.6.beta7]     from .utils import je, reindent_lines as ri
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/sage_setup/autogen/interpreters/utils.py", line 19, in <module>
[sagelib-9.6.beta7]     from jinja2 import Environment
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/jinja2/__init__.py", line 12, in <module>
[sagelib-9.6.beta7]     from .environment import Environment
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/jinja2/environment.py", line 25, in <module>
[sagelib-9.6.beta7]     from .defaults import BLOCK_END_STRING
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/jinja2/defaults.py", line 3, in <module>
[sagelib-9.6.beta7]     from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
[sagelib-9.6.beta7]   File "/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/jinja2/filters.py", line 13, in <module>
[sagelib-9.6.beta7]     from markupsafe import soft_unicode
[sagelib-9.6.beta7] ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/home/steffania/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages/markupsafe/__init__.py)
[sagelib-9.6.beta7] ************************************************************************
[sagelib-9.6.beta7] Error building the Sage library
[sagelib-9.6.beta7] ************************************************************************
[sagelib-9.6.beta7] Please email sage-devel (http://groups.google.com/group/sage-devel)
[sagelib-9.6.beta7] explaining the problem and including the relevant part of the log file
[sagelib-9.6.beta7]   /home/steffania/sage/logs/pkgs/sagelib-9.6.beta7.log
[sagelib-9.6.beta7] Describe your computer, operating system, etc.
[sagelib-9.6.beta7] ************************************************************************
[sagelib-9.6.beta7]
[sagelib-9.6.beta7] real    0m3,552s
[sagelib-9.6.beta7] user    0m3,213s
[sagelib-9.6.beta7] sys    0m0,318s
make[3]: *** [Makefile:2910: sagelib-SAGE_VENV-no-deps] Error 1
make[2]: *** [Makefile:2910: /home/steffania/sage/local/var/lib/sage/venv-python3.8/var/lib/sage/installed/sagelib-9.6.beta7] Error 2
make[1]: *** [Makefile:2475: all-build] Error 2
make[1]: Leaving directory '/home/steffania/sage/build/make'

real    0m7,981s
user    0m7,634s
sys    0m0,823s
***************************************************************
Error building Sage.

The following package(s) may have failed to build (not necessarily
during this run of 'make all-build'):

* package:         sagelib-9.6.beta7
  last build time: avril 7 11:59
  log file:        /home/steffania/sage/logs/pkgs/sagelib-9.6.beta7.log

It is safe to delete any log files and build directories, but they
contain information that is helpful for debugging build problems.
WARNING: If you now run 'make' again, the build directory of the
same version of the package will, by default, be deleted. Set the
environment variable SAGE_KEEP_BUILT_SPKGS=yes to prevent this.

make: *** [Makefile:39: all-build] Error 1

solution:

$ sage -pip install markupsafe==2.0.1
Collecting markupsafe==2.0.1
  Downloading MarkupSafe-2.0.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (30 kB)
Installing collected packages: markupsafe
  Attempting uninstall: markupsafe
    Found existing installation: MarkupSafe 2.1.1
    Uninstalling MarkupSafe-2.1.1:
      Successfully uninstalled MarkupSafe-2.1.1
Successfully installed markupsafe-2.0.1


Sébastien Labbé

unread,
Apr 7, 2022, 7:55:56 AM4/7/22
to sage-devel
or possibly the solution is to upgrade to a more recent jinja2 which would use markupsafe according to its version 2.1.1?

$ cat build/pkgs/jinja2/install-requires.txt
jinja2 >=2.11.2
$ cat build/pkgs/jinja2/dependencies
$(PYTHON) markupsafe docutils | $(PYTHON_TOOLCHAIN)


Matthias Koeppe

unread,
Apr 7, 2022, 2:00:26 PM4/7/22
to sage-devel
Are you sure jupyterlab was not installed with an earlier version of Sage? 
Because I think we fixed this in https://trac.sagemath.org/ticket/33607, which was merged in 9.6.beta6.

Try if re-installing jinja2 and markupsafe using "sage -f ...." fixes the problem

Sébastien Labbé

unread,
Apr 8, 2022, 8:01:19 AM4/8/22
to sage-devel
On Thursday, April 7, 2022 at 8:00:26 PM UTC+2 Matthias Koeppe wrote:
Are you sure jupyterlab was not installed with an earlier version of Sage? 

For my Student computer: it was not installed earlier.
For my computer on which I reproduced the issue: probably jupyterlab was installed before yes.
 
Because I think we fixed this in https://trac.sagemath.org/ticket/33607, which was merged in 9.6.beta6.

Try if re-installing jinja2 and markupsafe using "sage -f ...." fixes the problem

 
Yes, I confirm that doing

$ MAKE='make -j7' sage -f jinja2
$ MAKE='make -j7' sage -f markupsafe

fixes sage -n jupyterlab.

If I understand correctly, the above sage -f downgraded them to the following versions:

$ sage -pip install jinja2
Requirement already satisfied: jinja2 in ./GitBox/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages (2.11.2)
Requirement already satisfied: MarkupSafe>=0.23 in ./GitBox/sage/local/var/lib/sage/venv-python3.8/lib/python3.8/site-packages (from jinja2) (1.1.1)



Reply all
Reply to author
Forward
0 new messages