It *is* possible to use Leo as a sage notebook (within Ubuntu, not wsl). 
Right now, without changing Leo!


Two, no three, Ahas make this possible:


- Leo must run *within *Sage.

- Everything must be installed within Sage.

- Sage prompts are really ipython prompts.


*Installing Leo*


I installed Leo inside Sage:


sage: !pip install leo


The first time I ran Leo I got a familiar message:


sage: !leo

qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load 
the Qt xcb platform plugin.

qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even 
though it was found...


But now I knew what to do:


sage: !sudo apt-get install libxcb-cursor0


And now Leo worked!


sage: !leo

setting leoID from os.getenv('USER'): 'edreamleo'

Leo 6.8.1, 6.8.1 branch, build 616c868bbf

2024-07-24 05:19:21 -0500

Python 3.12.3, PyQt version 6.7.3

linux

wrote recent file: /home/edreamleo/.leo/.leoRecentFiles.txt


*Executing Sage scripts within Leo*


Here is a script from the Sage tutorial:


from sage.all import *

x = circle(

    (Integer(0),Integer(0)), Integer(1),

    rgbcolor=(Integer(1),Integer(1),Integer(0)))

print('x', x)

x.show()


When Leo runs inside sage we can run this script as a Leo script!! The 
output (in the Sage console) is:

x Graphics object consisting of 1 graphics primitive

Graphics object consisting of 1 graphics primitive


The graphic doesn't appear automatically, but I expect it will after 
configuring Sage's viewer.


*Summary*

Sage runs ipython in a separate environment, so:

- Installing packages outside Sage is *futile*.
- Leonine scripts can import sage *only *when Leo runs from within Sage.

With these insights, Leo becomes a Sage notebook!

All comments and questions are welcome.

Edward

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/leo-editor/1e2d0b2a-7e40-421a-9cef-7900ffe42554n%40googlegroups.com.

Reply via email to