Ask Your Question
2

How to install hide_code in SageMath?

asked 2020-03-17 02:46:33 +0100

JC gravatar image

updated 2020-03-19 16:54:27 +0100

Hi all,

I have sage 8.1 installed on Ubuntu 18.04. It works fine from the terminal, the deprecated notebook seems to work correctly as well. Hoewever when I launch sage -n jupyter and try to open/create an ipynb file, I get Error 500 : Internal Server Error.

Below, what I obtain from the terminal.

I certainly broke something during the weekend, I was trying to get the hide_code extension to work, and I clearly did something that I should not. I don't know precisely what, but I tried to intall jupyter lab, and many other manipulations.

Any suggestion?

Edit 1 I edited, as per Sébastien's first answer.

Edit 2 My question deviated towards the installation of hide_code for jupyter. @Sebastien answered, the procedure works fine!

Thanks in advance!

| SageMath version 8.1, Release Date: 2017-12-07 │

│ Type "notebook()" for the browser-based notebook interface. │

│ Type "help()" for help. │

Please wait while the Sage Jupyter Notebook server starts... File "/home/jcb/.local/lib/python2.7/site-packages/hide_code/hide_code.py", line 9, in <module> from hide_code.hide_code_html_exporter import HideCodeHTMLExporter ImportError: No module named hide_code_html_exporter

edit retag flag offensive close merge delete

Comments

One suggestion would be to install Sage 9.0. It was released in January, as opposed to 8.1, released late in 2017.

John Palmieri gravatar imageJohn Palmieri ( 2020-03-17 03:22:08 +0100 )edit

@JC: are you able to reproduce the same problem with sage version 9.0 ?

Sébastien gravatar imageSébastien ( 2020-03-18 19:56:49 +0100 )edit

Hello @Sebastien No, Sage 9.0 works fine. I did not install the hide-code extension yet, will tray later today.

JC gravatar imageJC ( 2020-03-19 01:10:14 +0100 )edit

2 Answers

Sort by » oldest newest most voted
3

answered 2020-03-17 14:07:05 +0100

Sébastien gravatar image

updated 2020-03-25 08:31:57 +0100

The error message ImportError: No module named hide_code_html_exporter means hide_code module seems to exist, but not the submodule hide_code_html_exporter. It seems to be a problem of versions. Maybe that submodule does not exist in the version you installed? Seems strange.

As John suggests, I would suggest to install the latest version of SageMath >=9 (notice that this now uses Python 3 syntax). After enabling ssl support to get pip to work (see other ask questions), then, you can install pip packages.

EDIT: I just manage to install hide_code on my Ubuntu machine running SageMath >=9.0. Below is what I did. The hide_code jupyter extension can be installed with:

cd SAGE_ROOT
./sage -pip install hide_code

This also installs the latest version of prompt-toolkit-3.0.4 which is a dependency of hide_code. But it turns out that the current hide_code (=hide-code-0.5.5) depends on a older version of prompt_toolkit<2.0.0,>=1.0.4. Therefore, I needed to install the following version of prompt_toolkit which uninstall the other one:

./sage -pip install prompt_toolkit==1.0.4

Then, I can complete the installation of hide_code with the following command run in the sage shell environnent that I obtained from here:

sage -sh
jupyter-nbextension install --py hide_code --sys-prefix
jupyter-nbextension enable --py hide_code --sys-prefix
jupyter-serverextension enable --py hide_code --sys-prefix

To learn how to use hide_codeis explained in a video in this page : https://github.com/kirbs-/hide_code

Moreover, to install jupyterlab, one may do:

./sage -pip install jupyterlab
edit flag offensive delete link more
0

answered 2020-03-19 02:37:41 +0100

JC gravatar image

updated 2020-09-03 03:04:18 +0100

slelievre gravatar image

@Sebastien I tried what you mention.

$ ./sage -pip install jupyterlab
$ ./sage -pip install RISE

Up to that point everything was kind of ok

Then I did

$ ./sage -pip install hide_code

(not hide-code) and that's where everything got screwed.

I am uncompressing the binaries again. But then I have two questions

  1. How to make jupyter to start in my /user directory instead of ../sage-9.0-Ubuntu_18.04-x86_64/SageMath$
  2. How do I install the hide_codeextension, or something allowing to obtain the same effect : to teach mathematics it is often useful to show only the result (perhaps a figure), and ignore the code. How to do this using RISE? I tried the instructions here https://github.com/kirbs-/hide_code but that failed.
edit flag offensive delete link more

Comments

  1. This allows to run jupyter or jupyterlab from any directory: ./sage -n jupyter --notebook-dir=<PATH-TO-CHOSEN-DIRECTORY>

  2. I never used hide_code myself. It is strange that it does not work: maybe there is a bug to be reported. It seems a good idea (which used to exist in the legacy sagenb notebook). Personally, when the code is long, I write it in a function in another cell or in a another file and call it from the notebook.

Sébastien gravatar imageSébastien ( 2020-03-19 09:35:02 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-03-17 02:46:33 +0100

Seen: 691 times

Last updated: Sep 03 '20