First time here? Check out the FAQ!

Ask Your Question
2

How to install hide_code in SageMath?

asked 5 years ago

JC gravatar image

updated 5 years ago

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

Preview: (hide)

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 ( 5 years ago )

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

Sébastien gravatar imageSébastien ( 5 years ago )

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

JC gravatar imageJC ( 5 years ago )

2 Answers

Sort by » oldest newest most voted
3

answered 5 years ago

Sébastien gravatar image

updated 5 years ago

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
Preview: (hide)
link
0

answered 5 years ago

JC gravatar image

updated 4 years ago

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.
Preview: (hide)
link

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 ( 5 years ago )

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: 5 years ago

Seen: 737 times

Last updated: Sep 03 '20