3-manifolds / Sage_macOS

SageMath as a macOS application bundle.
156 stars 15 forks source link

sagemath-9.3.app under macOS: can't connect to server for jupyter #5

Closed murrayE closed 3 years ago

murrayE commented 3 years ago

(This is from https://trac.sagemath.org/ticket/31814, where it might not be noticed because that trac system didn't allow me to specify sage 9.3 as the version!)

I sage-9.3-kernelStart_unhandled_error.txt installed Sage 9.3 app under macOS Big Sur (11.3.1) on Intel iMac. From SageMath-9-3.app I can run sage command-line in Terminal.

But I cannot seem to be able to use Sage from jupyter. I try to pen SageMath-9.3.app and choose "Jupyter notebook from folder" option, then Launch. I get error "Safari Can't Connect to the Server ... can't open the page 'localhost:8888/tree?token=......' because Safari can't connect to the server 'localhost'".

Further info: To start jupyter notebook, I have to start a conda environment in Terminal, then give command "jupyter notebook", which opens a jupyter notebook in Safari.

When the jupyter .ipynb notebook is open in Safari, it shows "Sage 9.3" as the kernel but I immediately see a Kernel error, which persists even if I try to restart the kernel or reconnect to it.

Part of the problem might be that the python being accessed is from the anaconda3 distribution, since I need that to even use the conda environment in Terminal in order to launch jupyter notebook.

The "Unhandled error" for the kernel ends with:

FileNotFoundError: [Errno 2] No such file or directory: '/var/tmp/sage-9.3.rc2-current/local/bin/sage' The complete text of the error message is attached.

Note that I can run, for example, a Julia 1.6.1 kernel from a jupyter notebook.

culler commented 3 years ago

Hi Murray, it looks like you installed SageMath-9.3.rc2 instead of the most recent release which is SageMath-9.3.rc4.

Can you please try with that latest (but soon to be obsolete) release?

culler commented 3 years ago

One other thing that you could also try is to first run the app but select the terminal option. That should create the symlink in /var/tmp. However, running the jupyter from conda rather than using the built-in jupyter server has not been tested and might fail for other reasons even if the symlink exists. And it really would be best to debug the rc4 release.

murrayE commented 3 years ago

So how do I start jupyter with sagemath-9.3.app if I do not use the conda environment?

culler commented 3 years ago

You double-click the app icon to start it, select the radio button for using the notebook interface, choose a directory for storing notebooks, then click the "Launch" button.

On Thu, May 20, 2021, 10:56 AM murrayE @.***> wrote:

So how do I start jupyter with sagemath-9.3.app if I do not use the conda environment?

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/3-manifolds/Sage_macOS/issues/5#issuecomment-845288212, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJ6CPYUFEAN5IDMTKH2AK3TOU5KXANCNFSM45HK25KQ .

murrayE commented 3 years ago

Sagemath 9.3 rc4 is working in jupyter. At first I thought not, but the problem was the notebook was trying kernel "Sage 9.3" rather than "Sage 9.3 rc4".

culler commented 3 years ago

Great! Thanks!

However, I think that you have found a bug in the "extras" package even if it is not affecting your launch. You should have a file /usr/local/share/jupyter/kernels/sagemath_9_3_all/kernel.json on your system, installed by that package. On my system I notice that it seems to contain information about the SageMath-9.2 app, meaning that I forgot to update that file in the package when I released the SageMath-9.3.rc4 app.

I will leave this ticket open for now, and close it when I fix the package for the final SageMath-9.3 release, which should happen in early June.

culler commented 3 years ago

the notebook was trying kernel "Sage 9.3" rather than "Sage 9.3 rc4".

I don't actually understand how you are running the app in order to make such an option available. I don't think that running it in the way that I expect could possibly lead to that. If you could provide details it would be appreciated.

NathanDunfield commented 3 years ago

I think I know what is going on. The 9.3 rc4 pkg installs into

/usr/local/share/jupyter/kernels/sagemath_9_3_all

an out of datekernel.json file with

{"argv": ["/var/tmp/sage-9.3.rc2-current/local/bin/sage", 
                 "--python", "-m", "sage.repl.ipython_kernel", 
                "-f", "{connection_file}"], 
"display_name": "Sage 9.3", 
"language": "sage"}

When I start Jupyter via SageMath-9-3.app and create a new notebook, there are two choices for the Sage kernel: Sage 9.3 and Sage 9.3.rc4. The former is tied to the above kernel.json file and doesn't work since argv points to a nonexistent location. The latter works just fine.

murrayE commented 3 years ago

I do have file /usr/local/share/jupyter/kernels/sagemath_9_3_all/kernel.json. In it I have files:

kernel.json logo-32x32.png logo-64x64.png logo.svg

And file kernel.json consists of the one line:

{"argv": ["/var/tmp/sage-9.3.rc2-current/local/bin/sage", "--python", "-m", "sage.repl.ipython_kernel", "-f", "{connection_file}"], "display_name": "Sage 9.3", "language": "sage"}

On my system I’ve now edited to correct the link to become "/var/tmp/sage-9.3.rc4-current/local/bin/sage” and to display the name as “Sage 9.3”.

On 20 May2021, at 2:40 PM, Marc Culler @.***> wrote:

Great! Thanks!

However, I think that you have found a bug in the "extras" package even if it is not affecting your launch. You should have a file /usr/local/share/jupyter/kernels/sagemath_9_3_all/kernel.json on your system, installed by that package. On my system I notice that it seems to contain information about the SageMath-9.2 app, meaning that I forgot to update that file in the package when I released the SageMath-9.3.rc4 app.

I will leave this ticket open for now, and close it when I fix the package for the final SageMath-9.3 release, which should happen in early June.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/3-manifolds/Sage_macOS/issues/5#issuecomment-845370899, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABILR2NH33SNY3LT3KTY2ADTOVJTDANCNFSM45HK25KQ.

—— Murray Eisenberg @. @.> Professor Emeritus Mathematics & Statistics Dept.
University of Massachusetts Amherst, MA USA

culler commented 3 years ago

Perfect! So that will get fixed in the real SageMath-9.3 release. In the meantime, editing that file as you did seems to be the best workaround. And I will continue to leave this ticket open to remind me.

culler commented 3 years ago

Now fixed in the real release.