3-manifolds / Sage_macOS

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

10.3 overwrites the installation to the version originally installed with 10.1 (preview). After installation, an error occurs when starting. #65

Closed n-WN closed 5 months ago

n-WN commented 5 months ago
sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.3, Release Date: 2024-03-19                    │
│ Using Python 3.11.1. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
Traceback (most recent call last):
  File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/bin/sage-ipython", line 12, in <module>
    from sage.repl.interpreter import SageTerminalApp
  File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/repl/interpreter.py", line 145, in <module>
    from sage.repl.prompts import InterfacePrompts
  File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/sage/repl/prompts.py", line 16, in <module>
    from IPython.terminal.prompts import Prompts
  File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/IPython/__init__.py", line 55, in <module>
    from .terminal.embed import embed
  File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/IPython/terminal/embed.py", line 15, in <module>
    from IPython.core.interactiveshell import DummyMod, InteractiveShell
  File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 326, in <module>
    class InteractiveShell(SingletonConfigurable):
  File "/private/var/tmp/sage-10.3-current/local/var/lib/sage/venv-python3.11.1/lib/python3.11/site-packages/IPython/core/interactiveshell.py", line 331, in InteractiveShell
    ast_transformers: List[ast.NodeTransformer] = List(
                      ~~~~^^^^^^^^^^^^^^^^^^^^^
TypeError: type 'List' is not subscriptable
culler commented 5 months ago

Thank you for reporting this. We did test 10.3 in the presence of older versions of SageMath, including 10.1, but we did not see anything like this. Of course, based on your earlier question you were expecting this. I am assuming that this has to do with PyPI packages that you installed with SageMath 10.1. Can you please try this:

$ mv ~/.sage ~/DOT_SAGE $ sage

(You can always move it back later.)

Please report what happens. If this works, maybe we can figure out what needs to be updated in your ~/.sage directory.

I don't know of anything (other than /usr/local/bin/sage) that would be overwritten by installing SageMath 10.3. When you say that something was overwriteen, what are you referring to?

culler commented 5 months ago

Looking at your traceback makes me suspect that SageMath-10.3 is crashing when it imports something from an IPython package installed in your ~/.sage directory. Can you check whether you have IPython installed in ~/.sage? If so, is there a reason why you need that?

n-WN commented 5 months ago

Looking at your traceback makes me suspect that SageMath-10.3 is crashing when it imports something from an IPython package installed in your ~/.sage directory. Can you check whether you have IPython installed in ~/.sage? If so, is there a reason why you need that?

cd ~/.sage/ && ls
R                db               ipython-5.0.0    local            maxima           temp
cache            gap              jupyter-4.1      matplotlib-1.5.1 pycache

There is indeed Ipython. I forgot why I installed it in the first place. Maybe I felt that the terminal interaction of sage is very similar to that of ipython. I wanted to test the difference between the installation and the installation.

culler commented 5 months ago

SageMath 10.3 includes IPython 8.18.1. It looks like you might have a copy of 5.0.0 installed in your ~/.sage directory. (The actual installation would be in ~/.sage/local/lib/python3.11/site-packages)

Did it help to temporarily move ~/.sage out of the way?

n-WN commented 5 months ago

SageMath 10.3 includes IPython 8.18.1. It looks like you might have a copy of 5.0.0 installed in your ~/.sage directory. (The actual installation would be in ~/.sage/local/lib/python3.11/site-packages)

Did it help to temporarily move ~/.sage out of the way?

It worked out. Thank you

cp -r .sage/ sageBackup/
rm -rf .sage/
cd sageBackup/
ls
R                db               ipython-5.0.0    local            maxima           temp
cache            gap              jupyter-4.1      matplotlib-1.5.1 pycache
sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.3, Release Date: 2024-03-19                    │
│ Using Python 3.11.1. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: GF(9)
Finite Field in z2 of size 3^2
n-WN commented 5 months ago

SageMath 10.3 includes IPython 8.18.1. It looks like you might have a copy of 5.0.0 installed in your ~/.sage directory. (The actual installation would be in ~/.sage/local/lib/python3.11/site-packages)

Did it help to temporarily move ~/.sage out of the way?

But I don’t know how to uninstall the previous version gracefully, rm -rf /var/tmp/sage-10.1-current? Then use jupyter kernelspec list to check and remove 10.1?

culler commented 5 months ago

1) Drag SageMath-10-1.app from /Applications to Trash. That will trigger Apple's update of their database of installed apps. 2) rm -rf ~/Library/Application\ Support/SageMath That removes settings and Jupyter runtime files for old versions. 3) sudo rm -rf /usr/local/share/jupyter/kernels/SageMath-10.1 That removes the jupyter kernel spec directory for SageMath 10.1 so it won't appear as a (broken) kernel option in your jupyter notebooks.

You will have to decide what to do about ~/.sage. You could just remove it and install new PyPI packages as needed, but you said you wanted to preserve some of those.

n-WN commented 5 months ago
  1. Drag SageMath-10-1.app from /Applications to Trash. That will trigger Apple's update of their database of installed apps.
  2. rm -rf ~/Library/Application\ Support/SageMath That removes settings and Jupyter runtime files for old versions.
  3. sudo rm -rf /usr/local/share/jupyter/kernels/SageMath-10.1 That removes the jupyter kernel spec directory for SageMath 10.1 so it won't appear as a (broken) kernel option in your jupyter notebooks.

You will have to decide what to do about ~/.sage. You could just remove it and install new PyPI packages as needed, but you said you wanted to preserve some of those.

  1. I have followed the three steps you mentioned and solved my previous dilemma very smoothly. Thank you very much.

  2. As for ~/.sage, I decided to completely delete the backup and reinstall it.

  3. There is another point I am not clear about: Why can the (Sagemath) jupyter kernel under Mac easily switch in the ipynb file of vscode, but win cannot? I am trying to make some Sagemath plug-ins, and found that if win users want to open nootbook in a non-browser, they always need to Open the browser version, then paste the token and url into the ipynb settings of vscode and select "Select other kernels--Add existing jupyter server only";

Although this last question has nothing to do with this issue, I am very concerned about how the technology of Sagemath 10.3, which allows you to see the jupyter kernel in the ipynb file of vscode after installation, is implemented

culler commented 5 months ago

I'm glad that your installation worked out.

I don't know if this will answer your question, but it might help. The jupyter server has a specific list of locations in the filesystem where it looks for kernels. On unix systems, this always includes /usr/local/share/jupyter/kernels. So our extra package installs a Jupyter kernel spec file for the Sage kernel in that directory. It sounds like vscode looks in the same places, but I don't know for sure whether it does. My suggestion would be to start with the Jupyter documentation and see what they say about search paths on Windows.

n-WN commented 5 months ago

I'm glad that your installation worked out.

I don't know if this will answer your question, but it might help. The jupyter server has a specific list of locations in the filesystem where it looks for kernels. On unix systems, this always includes /usr/local/share/jupyter/kernels. So our extra package installs a Jupyter kernel spec file for the Sage kernel in that directory. It sounds like vscode looks in the same places, but I don't know for sure whether it does. My suggestion would be to start with the Jupyter documentation and see what they say about search paths on Windows.

I'll go back and look at the files. Thank you!

n-WN commented 5 months ago

SageMath 10.3 includes IPython 8.18.1. It looks like you might have a copy of 5.0.0 installed in your ~/.sage directory. (The actual installation would be in ~/.sage/local/lib/python3.11/site-packages)

Did it help to temporarily move ~/.sage out of the way?

After the previous '.sage/' file was deleted, I successfully opened SageMath 10.3, today I was curious to see what was in the '.sage/' directory, but there was really ipython5.0.0, why is that, I installed: pycryptodome, gmpy2;

> cd ~/.sage
> ls -la
total 0
drwx------  11 lov3  staff   352 Mar 27 02:19 .
drwxr-x---+ 78 lov3  staff  2496 Mar 30 23:45 ..
drwxr-xr-x   3 lov3  staff    96 Mar 26 20:45 R
drwxr-xr-x   3 lov3  staff    96 Mar 30 18:00 cache
drwxr-xr-x   2 lov3  staff    64 Mar 26 20:45 db
drwxr-xr-x   3 lov3  staff    96 Mar 26 20:45 ipython-5.0.0
drwxr-xr-x   3 lov3  staff    96 Mar 27 02:19 local
drwxr-xr-x   2 lov3  staff    64 Mar 26 20:45 matplotlib-1.5.1
drwxr-xr-x   3 lov3  staff    96 Mar 26 21:51 maxima
drwxr-xr-x   4 lov3  staff   128 Mar 27 02:19 pycache
drwxr-xr-x   3 lov3  staff    96 Mar 26 20:45 temp
culler commented 5 months ago

That is a good question. I think those directories are used for settings files. But I am not sure.

I deleted my .sage directory and restarted the app. I found that I had the same files that you show. The ipython directory is empty. But I cannot explain why it has 5.0.0 when that is not the version of ipython running in Sage. Nor do I know what its purpose is.

In any case, those files do not seem to cause any trouble.