sage-shell-mode icon indicating copy to clipboard operation
sage-shell-mode copied to clipboard

incompatibility with iPython 5.0

Open topisani opened this issue 9 years ago • 12 comments

Some of that strongly disagrees with sage-shell mode! The repl buffer is not read-only, and nothing happens when i press enter or run sage-shell:send-input manually. ob-sagemath is also broken, but i assume its happening over here

topisani avatar Jul 19 '16 22:07 topisani

I built the latest Sage from the source by using the develop branch of the Sage source repository. It seems that the latest Sage uses IPython 4.2.1. And sage-shell-mode and ob-sagemath work properly for me.

Here is an output of sage --version.

    SageMath version 7.3.beta8, Release Date: 2016-07-14

And that of sage --ipython.

    Python 2.7.10 (default, Jul 20 2016, 07:51:14) 
    Type "copyright", "credits" or "license" for more information.

    IPython 4.2.1 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.

Is Sage properly installed? If you have an error when using sage-shell-mode, could you provide me the error message?

stakemori avatar Jul 19 '16 23:07 stakemori

i downgraded sage to 7.2-6, and ipython to 4.2.0. Sage worked fine with ipython 5.0, but sage-shell-mode had some issue, and i didnt get any error message. The fact that sage 7.2-7 didnt work with ipython 4.2 may have been some mistake on my end. Point is, i seem to have narrowed it down to sage-shell-mode not working well with ipython 5.0, and ill just stay away from that update for now.

Totally unrelated: Thanks a lot for this plugin, its gotten me one step closer to not having to install windows again when i go back to school in a month!

topisani avatar Jul 20 '16 00:07 topisani

I do not quite understand about "Sage worked fine with ipython 5.0". If I understand correctly, Sage provides ipython and its version is less than 5.0. How do you use Sage with ipython 5.0?

I do not understand the version number 7.2-7 either. The version number of Sage corresponds to a tag of the git repository. And recent tags are 7.2, 7.2.beta0, ..., 7.2.beta5, 7.3.beta0, ... and 7.3.beta8. What does the number 7.2-7 mean?

Also, does Sage work fine in the command line without Emacs?

Totally unrelated: Thanks a lot for this plugin, its gotten me one step closer to not having to install windows again when i go back to school in a month!

You are welcome!

stakemori avatar Jul 20 '16 00:07 stakemori

ah! i am on arch linux, and that is the sage version in their repositories, i just made the assumption that they were global sage version numbers, but they are probably not then. As for ipython, that was installed as a dependency by the package manager, and aparently not provided by sage, but that might be the underlying issue, sage shouldnt be using ipython 5.0 anyway.

So, since anything i type comes out confusing as hell, here is what i did:

  • installed sage (7.2-6) using the package manager (which brought along ipython 4.2 as a dependency)
  • set it up in emacs - worked great
  • ran the package manager's update command, which updated ipython to 5.0 and sage to whatever it is the arch repos call 7.2-7
  • tried it in emacs, the REPL was broken, and ob-sagemath blocks hung forever.
  • tried it in the terminal, no issues
  • downgraded ipython to 4.2 and sage to 7.2-6 (yep, i know that version makes no sense, but it shouldnt be important)
  • now it works great everywhere.

I dont believe the sage version is the issue, only ipython 5.0. But maybe the arch repos should have them as two different packages (ipython4 & ipython5)? anyway ill keep it downgraded for now, but since sage itself appears to work fine with ipython 5.0, im guessing its an issue on your end.

conclusion: sage-shell-mode doesnt work with ipython 5.0, and i dont know if it is supposed to.

topisani avatar Jul 20 '16 10:07 topisani

Thank you for the explanation. Now I understand your issue.

It seems very strange to me because sage-shell-mode does not depend on system-wide installed ipython and if Sage works fine in the terminal, then sage-shell-mode should also do. Actually I installed ipython 5.0.0 with sudo pip install ipython, but sage-shell-mode works properly (I use Ubuntu 16.04).

I will install arch linux and take look into the issue. Thanks for the report.

stakemori avatar Jul 20 '16 12:07 stakemori

sage-shell-mode in arch linux is broken because they merged this branch and Emacs's inferior shell does not work well with ipython 5.0 (see this document of ipython).

To avoid this problem, ipython 5.0 provides --simple-prompt option. But Sage does not have this option.

Sage with ipython 5.0 doesn't work in shell-mode, comint-mode or eshell. But it works fine in term-mode. So I will investigate term-mode.

Even if this problem is solved, sage-shell-mode (and ob-sagemath) do not work well with ipython 5.0, because run_cell is broken in ipython 5.0 and sage-shell-mode uses it.

stakemori avatar Jul 21 '16 12:07 stakemori

the arch repos recently upgraded to sage 7.3, and it still doesnt work with ipython 4.2. I will try building from source

topisani avatar Aug 08 '16 11:08 topisani

Thanks for reporting.

it still doesnt work with ipython 4.2

You mean ipython 5.0?

The master branch of the Sage repository uses the old prompt of ipython. So currently this problem does not happen if you build it from source. Actually, I use Sage 7.3 with sage-shell-mode on Ubuntu and it works fine.

To fix this bug, sage-shell-mode must treat some of escape sequences. I will implement it. Sorry for taking long time.

stakemori avatar Aug 08 '16 11:08 stakemori

sorry, what i meant was, the 7.3 version of sage in the arch repos, doesn't work with ipython 4.2. It requires 5.0

Didnt mean to rush you, just wanted to report, that to get sage working on arch with sage-shell-mode you still have to build from source, even with the new version of sage.

topisani avatar Aug 08 '16 16:08 topisani

Did you have any issues building sage from source on arch?

@topisani, I can successfully build Sage on arch as follows.

sudo pacman -S gcc-fortran perl
git clone https://github.com/sagemath/sage.git
cd sage
make distclean # You may need this if you previously had an error.
make
./sage # Sage runs successfully.

If you still have an error when building, please ask at https://groups.google.com/forum/#!forum/sage-support

stakemori avatar Aug 10 '16 02:08 stakemori

i was downloading the source from the website directly, the latest git version helped. Thanks a lot!

topisani avatar Aug 10 '16 05:08 topisani

This issue was (almost) fixed, though there still exists a minor problem.

To use sage-shell-mode with IPython 5, you need to install Emacs 24.4 or later and set sage-shell:use-prompt-toolkit to t. ob-sagemath also works well.

I found at least one problem. We can input multiple lines. But we cannot change indent level when inputting multiple lines. It is due to an issue of IPython .

So I keep this issue open for a while. Thanks for reporting.

stakemori avatar Sep 04 '16 22:09 stakemori