FriCAS + jFriCAS

34 views
Skip to first unread message

Ralf Hemmecke

unread,
May 1, 2022, 4:22:32 PM5/1/22
to fricas-devel
Hello,

unfortunately there were some issues at
https://github.com/fricas/jfricas/issues
claiming that jfricas didn't work although it worked perfectly for myself.

Kurt figured out that there were compatibility problems with the
webserver hunchentoot (that was loaded when jfricas started) and the
SBCL version on which the current 1,3,7 release is based on.

After quite some discussion and many wasted hours in finding a simple
way for a user to make jFriCAS work, I decided that the simplest method
is to put hunchentoot into the FRICASsys image and distribute it
together with FriCAS. The main goal was to make it simple for a user.

I have now compiled a binary FriCAS distribution that includes
hunchentoot and that works together with jfricas (no no -- not from PyPI).

I would like to ask the community to give feedback to

http://hemmecke.org/fricas/dist/1.3.7/

any (un)successful feedback is welcome.

Ralf (with quite a lot of help from Kurt and Qian)

Bill Page

unread,
May 2, 2022, 12:55:32 PM5/2/22
to fricas...@googlegroups.com
Ralf,

Thanks for this. I tried your installation procedure on my "Linux Mint
19.3 Tricia base: Ubuntu 18.04 bionic" system and everything seemed
to work fine except the installation of JupyText.

After performing the steps in
* (optional) Install JupyText
when I run
jfricas $FDIR/foo.input
or even just
jfricas
I get the error message:
[C 12:38:09.008 NotebookApp] Bad config encountered during initialization:
[C 12:38:09.008 NotebookApp] The 'contents_manager_class' trait of
<notebook.notebookapp.NotebookApp object at 0x7fa3b6333860> instance
must be a type, but 'jupytext.TextFileContentsManager' could not be
imported

When I checked the config file:
xed $HOME/.jupyter/jupyter_notebook_config.py
I noticed that the installation command
--
3. Make Jupytext available.

sed -i 's|^# *c.NotebookApp.contents_manager_class
=.*|c.NotebookApp.contents_manager_class =
"jupytext.TextFileContentsManager"|;s|^#
*c.NotebookApp.use_redirect_file = .*|c.NotebookApp.use_redirect_file
= False|' $HOME/.jupyter/jupyter_notebook_config.py
--
failed to add the line
c.NotebookApp.use_redirect_file = False
presumably because the file did not previously contain any line like
# *c.NotebookApp.use_redirect_file = .*

Adding the line manually did not help.

In any case I guess jupyter is really complaining about
"jupytext.TextFileContentsManager". Commenting this line out allows
jfricas to start again but obviously
jfricas $FDIR/foo.input
still does not work.

Regards,
Bill.
> --
> You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/8e7a57bb-42d4-3ab8-ccd4-8b03eca37090%40hemmecke.org.

Ralf Hemmecke

unread,
May 2, 2022, 1:06:21 PM5/2/22
to fricas-devel
On 02.05.22 18:55, Bill Page wrote:
> Ralf,
>
> Thanks for this. I tried your installation procedure on my "Linux Mint
> 19.3 Tricia base: Ubuntu 18.04 bionic" system and everything seemed
> to work fine except the installation of JupyText.
>
> After performing the steps in
> * (optional) Install JupyText
> when I run
> jfricas $FDIR/foo.input
> or even just
> jfricas
> I get the error message:
> [C 12:38:09.008 NotebookApp] Bad config encountered during initialization:
> [C 12:38:09.008 NotebookApp] The 'contents_manager_class' trait of
> <notebook.notebookapp.NotebookApp object at 0x7fa3b6333860> instance
> must be a type, but 'jupytext.TextFileContentsManager' could not be
> imported

Oh... I must change my website. I wrongly have included JupyText in the
sed command. Just install

source $FDIR/venv/jfricas/bin/activate
pip3 install jupytext

Then it will work. I'll update in a few minutes.

> Adding the line manually did not help.
>
> In any case I guess jupyter is really complaining about
> "jupytext.TextFileContentsManager". Commenting this line out allows
> jfricas to start again but obviously
> jfricas $FDIR/foo.input
> still does not work.

Yes. Loading an .input file only works if you have jupytext installed.

Thanks for testing.
BTW, I see a comment here...
https://github.com/fricas/jfricas/issues/4
I am currently recompiling the fricas binary with having

sudo apt remove libssl.1.0.0

But cannot remove libssl.1.1, because that is obviously needed on xubu
18.04 for cl-hunchentoot.

So I guess, my binary will only work with having libssl 1.1.
That is certainly NOT perfect. If someone has an idea what to do here,
would be greatly appreciated.

Ralf

Ralf Hemmecke

unread,
May 2, 2022, 1:33:01 PM5/2/22
to fricas-devel
> I am currently recompiling the fricas binary with having
>
> sudo apt remove libssl.1.0.0
>
> But cannot remove libssl.1.1, because that is obviously needed on xubu
> 18.04 for cl-hunchentoot.

Gosh... that gives (see below...).

It's obviously not that easy to distribute hunchentoot together with
FriCAS and have it working on a lot of Linux Distros. :-(

Ralf

WARNING: System definition file
#P"/usr/share/common-lisp/source/trivial-garbage/trivial-garbage.asd"
contains definition for system "trivial-garbage-tests". Please only
define "trivial-garbage" and secondary systems with a name starting with
"trivial-garbage/" (e.g. "trivial-garbage/test") in that file.
ASDF could not load hunchentoot because Unable to load any of the
alternatives:
("libssl.so.1.0.2" "libssl.so.1.0.1l" "libssl.so.1.0.1e"
"libssl.so.1.0.1j"
"libssl.so.1.0.1" "libssl.so.1.0.0q" "libssl.so.1.0.0"
"libssl.so.0.9.8ze"
"libssl.so.0.9.8" "libssl.so" "libssl.so.4" "libssl.so.10").

debugger invoked on a CFFI:LOAD-FOREIGN-LIBRARY-ERROR in thread
#<THREAD "main thread" RUNNING {10005F05B3}>:
Unable to load any of the alternatives:
("libssl.so.1.0.2" "libssl.so.1.0.1l" "libssl.so.1.0.1e"
"libssl.so.1.0.1j"
"libssl.so.1.0.1" "libssl.so.1.0.0q" "libssl.so.1.0.0"
"libssl.so.0.9.8ze"
"libssl.so.0.9.8" "libssl.so" "libssl.so.4" "libssl.so.10")

Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
0: [RETRY ] Try loading the foreign library again.
1: [USE-VALUE ] Use another library instead.
2: [TRY-RECOMPILING ] Recompile reload and try loading
it again
3: [RETRY ] Retry
loading FASL for #<CL-SOURCE-FILE
"cl+ssl" "src" "reload">.
4: [ACCEPT ] Continue, treating
loading FASL for #<CL-SOURCE-FILE
"cl+ssl" "src" "reload">
as having been successful.
5: Retry ASDF operation.
6: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after
resetting the
configuration.
7: Retry ASDF operation.
8: Retry ASDF operation after
resetting the
configuration.
9: [ABORT ] Exit debugger, returning to top level.

(CFFI::FL-ERROR "Unable to load any of the alternatives:~% ~S"
("libssl.so.1.0.2" "libssl.so.1.0.1l" "libssl.so.1.0.1e"
"libssl.so.1.0.1j" "libssl.so.1.0.1" "libssl.so.1.0.0q"
"libssl.so.1.0.0" "libssl.so.0.9.8ze" "libssl.so.0.9.8" "libssl.so"
"libssl.so.4" "libssl.so.10"))
source: (ERROR 'LOAD-FOREIGN-LIBRARY-ERROR :FORMAT-CONTROL CONTROL
:FORMAT-ARGUMENTS ARGUMENTS)
0]

Ralf Hemmecke

unread,
May 2, 2022, 3:28:54 PM5/2/22
to fricas...@googlegroups.com
Hi Bill,

thank you for your feedback.

On 02.05.22 18:55, Bill Page wrote:
Oh... in your case jupyter_notebook_config.py was probably existing.
However, this redirect line was for me only necessary in Ubuntu 22.04.
There when starting "jupyter notebook", firefox would open with a
file://... URL and it would not redirect to the localhost URL where
Jupyter is running.

The actual problem is the jupytext line. What happened to
c.NotebookApp.contents_manager_class in your case? Obviously it points
to jupytext. But then I can only guess that jupytext was not installed
in the virtualenv ($HOME/fricas/venv).

Ralf

Bill Page

unread,
May 2, 2022, 3:57:50 PM5/2/22
to fricas...@googlegroups.com
I do not know. I did not check first. Instead I just ran
jupyter notebook --generate-config
It did not prompt for Overwrite [y/N]. But I just re-ran this and I
now get a prompt so maybe it did not exist before.

wspage@desktop:~$ FDIR=$HOME/fricas
wspage@desktop:~$ source $FDIR/venv/jfricas/bin/activate
(jfricas) wspage@desktop:~$ jupyter notebook --generate-config
Overwrite /home/wspage/.jupyter/jupyter_notebook_config.py with
default config? [y/N]y
Writing default config to: /home/wspage/.jupyter/jupyter_notebook_config.py
(jfricas) wspage@desktop:~$

After re-creating the config file I tried running

(jfricas) wspage@desktop:~$ jfricas $FDIR/foo.input
[I 15:39:56.185 NotebookApp] Serving notebooks from local directory:
/home/wspage/fricas
[I 15:39:56.185 NotebookApp] 0 active kernels
[I 15:39:56.185 NotebookApp] The Jupyter Notebook is running at:
[I 15:39:56.185 NotebookApp]
http://localhost:8888/?token=c5c300794e7855ba2e9e1d32a372041518f27089419dcef2
[I 15:39:56.185 NotebookApp] Use Control-C to stop this server and
shut down all kernels (twice to skip confirmation).
[C 15:39:56.186 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=c5c300794e7855ba2e9e1d32a372041518f27089419dcef2
Opening in existing browser session.
[I 15:39:56.407 NotebookApp] Accepting one-time-token-authenticated
connection from 127.0.0.1
[I 15:39:56.409 NotebookApp] 302 GET
/notebooks/foo.input?token=8e615b4584b8a40575df4f1e176fd07aec2bb0759a9678d1
(127.0.0.1) 2.81ms
[1923:1923:0100/000000.497003:ERROR:sandbox_linux.cc(378)]
InitializeSandbox() called with multiple threads in process
gpu-process.
--

But nothing happens. I do not see anything in my browser. But I can
see that Jupyter is running if I enter
http://localhost:8888/?token=c5c300794e7855ba2e9e1d32a372041518f27089419dcef2
in the browser. If I logout and then exit (control-C) the Jupyter
session in the terminal, then

The Jupyter Notebook is running at:
http://localhost:8888/?token=c5c300794e7855ba2e9e1d32a372041518f27089419dcef2
Shutdown this notebook server (y/[n])? y
[C 15:44:10.548 NotebookApp] Shutdown confirmed
[I 15:44:10.549 NotebookApp] Shutting down 0 kernels
(jfricas) wspage@desktop:~$ jfricas
[I 15:44:31.826 NotebookApp] Serving notebooks from local directory:
/home/wspage
[I 15:44:31.826 NotebookApp] 0 active kernels
[I 15:44:31.826 NotebookApp] The Jupyter Notebook is running at:
[I 15:44:31.826 NotebookApp]
http://localhost:8888/?token=ae4481782fec549879e4ac2ed811328753aa618b148768dc
[I 15:44:31.826 NotebookApp] Use Control-C to stop this server and
shut down all kernels (twice to skip confirmation).
[C 15:44:31.827 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=ae4481782fec549879e4ac2ed811328753aa618b148768dc
[I 15:44:32.036 NotebookApp] Accepting one-time-token-authenticated
connection from 127.0.0.1
Opening in existing browser session.
[2284:2284:0502/154432.061548:ERROR:broker_posix.cc(43)] Invalid node
channel message
[2279:2279:0100/000000.128409:ERROR:sandbox_linux.cc(378)]
InitializeSandbox() called with multiple threads in process
gpu-process.
[2279:2279:0100/000000.128700:ERROR:broker_posix.cc(43)] Invalid node
channel message
[W 15:44:32.331 NotebookApp] 404 GET
/static/components/moment/locale/en-ca.js?v=20220502154431 (127.0.0.1)
6.21ms referer=http://localhost:8888/tree
--
Then a new tab appears in my browser as expected normally.

> However, this redirect line was for me only necessary in Ubuntu 22.04.
> There when starting "jupyter notebook", firefox would open with a
> file://... URL and it would not redirect to the localhost URL where
> Jupyter is running.

Maybe I still need the redirect line? Should I add it manually or
should the sed script be modified a little?

> The actual problem is the jupytext line. What happened to
> c.NotebookApp.contents_manager_class in your case? Obviously it points
> to jupytext.

Yes. I see
--
## The config manager class to use
#c.NotebookApp.config_manager_class =
'notebook.services.config.manager.ConfigManager'

## The notebook manager class to use.
c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"

## Extra keyword arguments to pass to `set_secure_cookie`. See tornado's
# set_secure_cookie docs for details.
#c.NotebookApp.cookie_options = {}
--
in the editor
xed $HOME/.jupyter/jupyter_notebook_config.py

I see the following when I install
--
(jfricas) wspage@desktop:~$ pip3 install jupytext
The directory '/home/wspage/.cache/pip/http' or its parent directory
is not owned by the current user and the cache has been disabled.
Please check the permissions and owner of that directory. If executing
pip with sudo, you may want sudo's -H flag.
The directory '/home/wspage/.cache/pip' or its parent directory is not
owned by the current user and caching wheels has been disabled. check
the permissions and owner of that directory. If executing pip with
sudo, you may want sudo's -H flag.
Requirement already satisfied: jupytext in
./fricas/venv/jfricas/lib/python3.6/site-packages
Requirement already satisfied: toml in
./fricas/venv/jfricas/lib/python3.6/site-packages (from jupytext)
Requirement already satisfied: pyyaml in
./fricas/venv/jfricas/lib/python3.6/site-packages (from jupytext)
Requirement already satisfied: mdit-py-plugins in
./fricas/venv/jfricas/lib/python3.6/site-packages (from jupytext)
Requirement already satisfied: markdown-it-py<3.0.0,>=1.0.0 in
./fricas/venv/jfricas/lib/python3.6/site-packages (from jupytext)
Requirement already satisfied: nbformat in
./fricas/venv/jfricas/lib/python3.6/site-packages (from jupytext)
Requirement already satisfied: typing-extensions>=3.7.4;
python_version < "3.8" in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
markdown-it-py<3.0.0,>=1.0.0->jupytext)
Requirement already satisfied: mdurl~=0.1 in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
markdown-it-py<3.0.0,>=1.0.0->jupytext)
Requirement already satisfied: attrs<22,>=19 in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
markdown-it-py<3.0.0,>=1.0.0->jupytext)
Requirement already satisfied: traitlets>=4.1 in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
nbformat->jupytext)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
nbformat->jupytext)
Requirement already satisfied: jupyter-core in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
nbformat->jupytext)
Requirement already satisfied: ipython-genutils in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
nbformat->jupytext)
Requirement already satisfied: six in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
traitlets>=4.1->nbformat->jupytext)
Requirement already satisfied: decorator in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
traitlets>=4.1->nbformat->jupytext)
Requirement already satisfied: importlib-metadata; python_version <
"3.8" in ./fricas/venv/jfricas/lib/python3.6/site-packages (from
jsonschema!=2.5.0,>=2.4->nbformat->jupytext)
Requirement already satisfied:
pyrsistent!=0.17.0,!=0.17.1,!=0.17.2,>=0.14.0 in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
jsonschema!=2.5.0,>=2.4->nbformat->jupytext)
Requirement already satisfied: zipp>=0.5 in
./fricas/venv/jfricas/lib/python3.6/site-packages (from
importlib-metadata; python_version <
"3.8"->jsonschema!=2.5.0,>=2.4->nbformat->jupytext)
--

But running this command:

(jfricas) wspage@desktop:~$ jfricas $FDIR/foo.input
The Jupyter HTML Notebook.

This launches a Tornado based HTML Notebook Server that serves up an
HTML5/Javascript Notebook client.

Subcommands
-----------
...
To see all available configurables, use `--help-all`

Examples
--------

jupyter notebook # start the notebook
jupyter notebook --certfile=mycert.pem # use SSL/TLS certificate
jupyter notebook password # enter a password to
protect the server

[C 15:52:30.108 NotebookApp] Bad config encountered during initialization:
[C 15:52:30.108 NotebookApp] The 'contents_manager_class' trait of
<notebook.notebookapp.NotebookApp object at 0x7fbd8def4860> instance
must be a type, but 'jupytext.TextFileContentsManager' could not be
imported
(jfricas) wspage@desktop:~$
--
Still gives the above error.

> But then I can only guess that jupytext was not installed
> in the virtualenv ($HOME/fricas/venv).
>

The output of
pip3 install jupytext
seems to suggest otherwise. Is there something else I can check?

Bill.

Ralf Hemmecke

unread,
May 2, 2022, 4:41:19 PM5/2/22
to fricas...@googlegroups.com
> But nothing happens. I do not see anything in my browser. But I can
> see that Jupyter is running if I enter
> http://localhost:8888/?token=c5c300794e7855ba2e9e1d32a372041518f27089419dcef2
> in the browser. If I logout and then exit (control-C) the Jupyter
> session in the terminal, then

Yes, that also puzzled me in the beginning. That problem should go away
if you set

c.NotebookApp.use_redirect_file = False

in $HOME/.jupyter/jupyter_notebook_config.py (under the assumption that
you describe the same problem that I saw in Ubuntu 22.04).

> Maybe I still need the redirect line? Should I add it manually or
> should the sed script be modified a little?

Can you figure out why the sed script didn't work? There obviously can
be bugs, since I only claim that it "works for me". ;-)

>> The actual problem is the jupytext line. What happened to
>> c.NotebookApp.contents_manager_class in your case? Obviously it points
>> to jupytext.
>
> Yes. I see
> --
> c.NotebookApp.contents_manager_class = "jupytext.TextFileContentsManager"
> --

Looks fine.

> I see the following when I install
> --
> (jfricas) wspage@desktop:~$ pip3 install jupytext

Do you see a jupytext directory under
./fricas/venv/jfricas/lib/python3.6/site-packages
?

> But running this command:
>
> (jfricas) wspage@desktop:~$ jfricas $FDIR/foo.input

Hmmmm... what actually ended up in the jfricas script?

You should see

=====
source /home/wspage/fricas/venv/jfricas/bin/activate
jupyter notebook $1
=====

I somehow have the suspicion that you have another jupyter installed and
"jfricas" does not switch on the virtualenv under $HOME/fricas. I
remember that I saw a similar output to what you reported and then
realized that my paths were messed up and I even called the wrong
jfricas (of course with differnt content).

Hope that helps.

Ralf

Xav Blue

unread,
May 4, 2022, 12:33:56 PM5/4/22
to FriCAS - computer algebra system
I didn't try JupyText yet but your FriCAS binaries work fine for me.
Some comments :
- I'm on Manjaro(ArchLinux) and libssl.so... are in /usr/lib
- I think there's a typo in §3 of your instructions for " Install Jupyter and jFriCAS." :
cd $FDIR/jfricas    ---->    cd $FDIR/venv/jfricas

Anyway thank you very much for beeing able now to use FriCas with Jupyter !
Xavier  (MrBlueXav)


Ralf Hemmecke

unread,
May 4, 2022, 3:19:11 PM5/4/22
to fricas-devel, mrbl...@gmail.com
On 04.05.22 18:32, Xav Blue wrote:
> I didn't try JupyText yet but your FriCAS binaries work fine for me.
> Some comments :
> - I'm on Manjaro(ArchLinux) and libssl.so... are in
> */usr/lib *

Thanks for trying. I have now also added a section on
http://hemmecke.org/fricas/dist/1.3.7/ that even removes the need for
root permission when there is not libssl.so.1.0.0

The following works for Ubuntu 22.04 other people must probably adapt
the "/usr/lib/..." path accordingly.

==============
If you have no sudo right do the following.

ln -s /usr/lib/x86_64-linux-gnu/libssl.so.3 $L/lib/libssl.so.1.0.0
sed -i "s|^export FRICAS\$|export
FRICAS\nLD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$L/lib\"\nexport
LD_LIBRARY_PATH|" $L/bin/fricas
sed -i "s|^export FRICAS\$|export
FRICAS\nLD_LIBRARY_PATH=\"\$LD_LIBRARY_PATH:$L/lib\"\nexport
LD_LIBRARY_PATH|" $L/bin/efricas
==============

> - I think there's a typo in §3 of your instructions for " Install Jupyter
> <https://jupyter.org/> and jFriCAS <https://jfricas.readthedocs.io>." :
> *cd $FDIR/jfricas ----> cd $FDIR/venv/jfricas*

Definitely not.

cd $FDIR/jfricas

goes to the git repository of jfricas. That is where the setup.py lies.

under $FDIR/venv/jfricas are the files that will be installed by pip3.

Jupytext is really cool, because it allows you to put your "notebooks"
under git without all the clutter of the .ipynb format. And if you like
the .ipynb, no problem, JupyText can synchronize .input and .ipynb
files, i.e. you would see both formats on your disk with the "same"
content, only that the .input format does not include the output.
Jupytext even takes care when you have change the .input file in your
text editor while you work in the .ipynb notebook. It will ask you to
reload.

> Anyway thank you very much for beeing able now to use FriCas with Jupyter !

You are welcome.

BTW, may I ask for what you use FriCAS?

Ralf
Reply all
Reply to author
Forward
0 new messages