SharedInstall-OCaml-Jupyter-in-CoCalc.mdOpen in CoCalc
Authors: Matjaž Krnc, Samuel Lelièvre, Pascal Ortiz, Harald Schilly
Views : 39
Description: Install ocaml-jupyter in CoCalc project

Install OCaml-Jupyter in a CoCalc project

Author: Samuel Lelièvre

Date: 2019-01-15

License: CC0

Goal

The goal here is to install ocaml-jupyter in a CoCalc project.

This is to help with

Installation

Overview:

  • In a CoCalc project, we will open a terminal and follow (with slight modifications) the instructions from the ocaml-jupyter README.

  • The slight modifications consist in

    • starting with `opam init``
    • installing the jupyter kernel with --user

The installation goes as follows:

~$ opam init
Checking for available remotes: rsync and local, git, mercurial, darcs. Perfect!

=-=- Fetching repository information =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[default] synchronized from https://opam.ocaml.org
[NOTE] The repository 'default' will be *permanently* redirected to https://opam.ocaml.org/1.2.2 (opam-version < "2.0~")
[default] synchronized from https://opam.ocaml.org/1.2.2

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
∗  installed base-bigarray.base
∗  installed base-threads.base
∗  installed base-unix.base
Done.

In normal operation, OPAM only alters files within ~/.opam.

During this initialisation, you can allow OPAM to add information to two
other files for best results. You can also make these additions manually
if you wish.

If you agree, OPAM will modify:

  - ~/.bash_profile (or a file you specify) to set the right environment
    variables and to load the auto-completion scripts for your shell (bash)
    on startup. Specifically, it checks for and appends the following line:

    . /home/user/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true


  - ~/.ocamlinit to ensure that non-system installations of `ocamlfind`
    (i.e. those installed by OPAM) will work correctly when running the
    OCaml toplevel. It does this by adding $OCAML_TOPLEVEL_PATH to the list
    of include directories.

If you choose to not configure your system now, you can either configure
OPAM manually (instructions will be displayed) or launch the automatic setup
later by running:

   opam config setup -a


Do you want OPAM to modify ~/.bash_profile and ~/.ocamlinit?
(default is 'no', use 'f' to name a file other than ~/.bash_profile)
    [N/y/f] y

User configuration:
  Generating ~/.ocamlinit.
  Updating ~/.bash_profile.
Global configuration:
  Updating ~/.opam/opam-init/init.sh
  Updating ~/.opam/opam-init/init.zsh
  Updating ~/.opam/opam-init/init.csh
  Updating ~/.opam/opam-init/init.fish
# To setup the new switch in the current shell, you need to run:
eval `opam config env`
~$ opam install jupyter
The following actions will be performed:
  ∗  install conf-zmq                0.1         [required by zmq]
  ∗  install conf-perl               1           [required by zarith]
  ∗  install conf-m4                 1           [required by ocamlfind]
  ∗  install conf-gmp                1           [required by conf-gmp-powm-sec, zarith]
  ∗  install conf-pkg-config         1.1         [required by conf-zlib]
  ∗  install dune                    1.2.1       [required by jupyter]
  ∗  install conf-which              1           [required by biniou]
  ∗  install ocamlbuild              0.12.0      [required by ppx_deriving_yojson, cryptokit, logs, uuidm]
  ∗  install ocamlfind               1.8.0       [required by ppx_deriving_yojson, cryptokit, logs, uuidm]
  ∗  install conf-gmp-powm-sec       1           [required by cryptokit]
  ∗  install conf-zlib               1           [required by cryptokit]
  ∗  install jbuilder                transition  [required by zmq, lwt_ppx, base64, etc.]
  ∗  install zarith                  1.7         [required by cryptokit]
  ∗  install ppx_tools               5.0+4.05.0  [required by ppx_deriving]
  ∗  install base-bytes              base        [required by stdint, base64, uuidm]
  ∗  install sexplib0                v0.11.0     [required by base]
  ∗  install result                  1.3         [required by logs, ppx_deriving_yojson]
  ∗  install ppx_derivers            1.0         [required by ppx_deriving]
  ∗  install easy-format             1.3.1       [required by yojson]
  ∗  install cppo                    1.6.5       [required by ppx_deriving_yojson]
  ∗  install cryptokit               1.13        [required by jupyter]
  ∗  install stdint                  0.5.1       [required by jupyter]
  ∗  install base64                  2.2.0       [required by jupyter]
  ∗  install base                    v0.11.1     [required by configurator]
  ∗  install topkg                   0.9.1       [required by logs, uuidm]
  ∗  install ocaml-migrate-parsetree 1.0.11      [required by lwt_ppx]
  ∗  install biniou                  1.2.0       [required by yojson]
  ∗  install lwt                     4.1.0       [required by jupyter]
       For Lwt_log and Lwt_daemon, please install package lwt_log
  ∗  install cppo_ocamlbuild         1.6.0       [required by ppx_deriving_yojson]
  ∗  install stdio                   v0.11.0     [required by configurator]
  ∗  install uuidm                   0.9.6       [required by jupyter]
  ∗  install ppx_tools_versioned     5.2.1       [required by lwt_ppx]
  ∗  install yojson                  1.4.1       [required by jupyter]
  ∗  install logs                    0.6.2       [required by jupyter]
  ∗  install ppx_deriving            4.2.1       [required by ppx_deriving_yojson]
  ∗  install configurator            v0.11.0     [required by zmq]
  ∗  install lwt_ppx                 1.2.1       [required by jupyter]
  ∗  install ppx_deriving_yojson     3.1         [required by jupyter]
  ∗  install zmq                     5.0.0       [required by jupyter]
  ∗  install zmq-lwt                 5.0.0       [required by jupyter]
  ∗  install jupyter                 2.3.3
===== ∗  41 =====
Do you want to continue ? [Y/n] y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[default] https://opam.ocaml.org/1.2.2/archives/base64.2.2.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/biniou.1.2.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/configurator.v0.11.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/cppo.1.6.5+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/base.v0.11.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/cppo_ocamlbuild.1.6.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/cryptokit.1.13+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/easy-format.1.3.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/dune.1.2.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/logs.0.6.2+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/jupyter.2.3.3+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/lwt.4.1.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/lwt_ppx.1.2.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ocaml-migrate-parsetree.1.0.11+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ocamlbuild.0.12.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ppx_derivers.1.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ocamlfind.1.8.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ppx_deriving.4.2.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ppx_deriving_yojson.3.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ppx_tools.5.0+4.05.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/result.1.3+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/ppx_tools_versioned.5.2.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/sexplib0.v0.11.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/stdint.0.5.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/stdio.v0.11.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/uuidm.0.9.6+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/topkg.0.9.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/yojson.1.4.1+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/zmq.5.0.0+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/zarith.1.7+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/zmq-lwt.5.0.0+opam.tar.gz downloaded

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
∗  installed conf-perl.1
∗  installed conf-m4.1
∗  installed conf-pkg-config.1.1
∗  installed conf-which.1
∗  installed conf-gmp.1
∗  installed conf-zmq.0.1
∗  installed conf-zlib.1
∗  installed conf-gmp-powm-sec.1
∗  installed ocamlfind.1.8.0
∗  installed base-bytes.base
∗  installed ppx_tools.5.0+4.05.0
∗  installed ocamlbuild.0.12.0
∗  installed zarith.1.7
∗  installed dune.1.2.1
∗  installed jbuilder.transition
∗  installed base64.2.2.0
∗  installed easy-format.1.3.1
∗  installed ppx_derivers.1.0
∗  installed cppo.1.6.5
∗  installed result.1.3
∗  installed biniou.1.2.0
∗  installed cryptokit.1.13
∗  installed cppo_ocamlbuild.1.6.0
∗  installed sexplib0.v0.11.0
∗  installed stdint.0.5.1
∗  installed ocaml-migrate-parsetree.1.0.11
∗  installed lwt.4.1.0
∗  installed topkg.0.9.1
∗  installed base.v0.11.1
∗  installed ppx_deriving.4.2.1
∗  installed ppx_tools_versioned.5.2.1
∗  installed logs.0.6.2
∗  installed stdio.v0.11.0
∗  installed uuidm.0.9.6
∗  installed configurator.v0.11.0
∗  installed lwt_ppx.1.2.1
∗  installed yojson.1.4.1
∗  installed zmq.5.0.0
∗  installed zmq-lwt.5.0.0
∗  installed ppx_deriving_yojson.3.1
∗  installed jupyter.2.3.3
Done.

=-=- jbuilder.transition installed successfully -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> Jbuilder has been renamed and the jbuilder package is now a transition package. Use the dune package instead.

=-=- jupyter.2.3.3 installed successfully -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> Please run for registration of ocaml-jupyter kernel:
=>
=> $ jupyter kernelspec install --name ocaml-jupyter \
=> /home/user/.opam/system/share/jupyter
=> $ jupyter kernelspec install --name ocaml-jupyter \
=> /home/user/.opam/system/share/jupyter
~$ opam install jupyter-archimedes
The following actions will be performed:
  ∗  install conf-cairo         1             [required by cairo2]
  ∗  install camlp4             4.05+system   [required by archimedes]
  ∗  install cairo2             0.5           [required by jupyter-archimedes]
  ∗  install archimedes         0.4.18        [required by jupyter-archimedes]
  ∗  install jupyter-archimedes 2.3.2
===== ∗  5 =====
Do you want to continue ? [Y/n] y

=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[default] https://opam.ocaml.org/1.2.2/archives/camlp4.4.05+system+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/cairo2.0.5+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/archimedes.0.4.18+opam.tar.gz downloaded
[default] https://opam.ocaml.org/1.2.2/archives/jupyter-archimedes.2.3.2+opam.tar.gz downloaded

=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
∗  installed camlp4.4.05+system
∗  installed conf-cairo.1
∗  installed cairo2.0.5
∗  installed archimedes.0.4.18
∗  installed jupyter-archimedes.2.3.2
Done.
~$ jupyter kernelspec install --name ocaml-jupyter --user "$(opam config var share)/jupyter"
[InstallKernelSpec] Installed kernelspec ocaml-jupyter in /home/user/.local/share/jupyter/kernels/ocaml-jupyter

Download some example Jupyter notebook worksheets:

~$ curl -O https://raw.githubusercontent.com/akabe/ocaml-jupyter/master/notebooks/introduction.ipynb
~$ curl -O https://raw.githubusercontent.com/akabe/ocaml-jupyter/master/notebooks/word_description_from_DuckDuckGoAPI.ipynb

Testing

In my testing with CoCalc-Jupyter, evaluating the code cells produces no output...

With Plain Jupyter, the kernel appears as "not trusted". I click "Trust"^ to trust it. It still stays "Connecting" and then "Cannot connect to thenotebook."

To be debugged...

For a larger collection of notebooks to try, see