Leointeg - A beginner fumbles!

179 views
Skip to first unread message

Israel Hands

unread,
Aug 21, 2023, 6:00:10 AM8/21/23
to leo-editor
Everyone now and then I upgrade something and I always find it harder than I should. That's my fault. So when I saw Ed's advice about installing Leointeg as the easiest way to go I thought - 'I'll give that a try'

And so I installed Leointeg - I'm running Leo 7.21 on Windows 10. And then I turned to websockets and thought maybe I ought to upgrade my Python install from 3.7. 

Strangely (or maybe not) before upgrading if ran the comman python from the command line Windows would complain about not finding python. But if I ran py all was well. 

Anyway - I installed Python 3.11.4 and then pip and then websockets and then tried running Leointeg but got the same error message I had before I installed websockets. 
Leo server exited with code 1. 
I then wondered what version of Python Leo was looking at so I started Leo as per normal, which failed with:

Can not load pyQt5 or pyQt6

Can not Import Qt

I now don't feel so good!

ta

IH

Israel Hands

unread,
Aug 21, 2023, 6:26:16 AM8/21/23
to leo-editor
I've just run the installer for pyqt6 from the python 3.11.4 directory and Leo now works again. School boy error. But Leointeg still fails -I'm running Leo 7.21 - maybe that needs an update?

ta

IH

Félix

unread,
Aug 21, 2023, 1:14:05 PM8/21/23
to leo-editor
Hi Israel, 

I'm Félix, the creator of LeoInteg. I'm glad to have people tryout LeoInteg! Thanks for giving it a try!! :)

I've successfully ran leointeg on many oses without any fuss, (windows, ubuntu, and even raspberry pi on a PI 3) using the simple commands shown here :  (But I know sometimes it's not that simple or easy - so I'll try to help you out !)
testscreen2.png

First things first, to get you going, I gotta ask: what is this Leo 7.21 that you speak of? Are you from the future? 😅 the latest Leo is 6.7.4! (or 6.7.5 in development) Please take a screenshot of your Leo window at startup so we can see what you see here: 
Screenshot from 2023-08-21 12-36-24.png
Next, take a screenshot of your LeoInteg Settings, which you can see if you use the "Welcome" command from LeoInteg in VSCode. (press F1 or Ctrl+shift+P to open the command palette, and start typing "Leo Welcome" to see the command and press enter) So that we can wee what you have setup, the screen looks like this (the important sections are "Leo-Editor Path" and "Python Command" ):
Screenshot from 2023-08-21 12-39-47.png
When you setup the options and press 'start server' on the LEO INTEGRATION panel on the left, you will see something like this in the Leo Output panel:
(Note: This command line is built with the options you put in the settings above)
testoutput-leo-leo.png

Obviously you may get the error instead of a "success" but at least you will see what command LeoInteg tried to launch the server with. Please provide it in you reply so we can see, and diagnose a bit more.

Another good test that I would suggest, is to manually start the server to get better error messages : In a terminal, navigate to your Leo-Editor installation folder, then 'cd' into the /leo-editor/leo/core/ folder. Then, try to launch the leoserver.py script directly as such: 

On my linux machine I can start it like this: python3.10 leoserver.py
On my windows machine i start it like this: py leoserver.py.

Try to see if you can start the server by launching it manually instead of automatically with LeoInteg, What does that do? Is it possible to start it successfully this way?

If it works you can then try connecting with leointeg with the 'Connect' button in the Leo Integration panel on the left. (no need to 'start' a server with leointeg if you started one manually.) And note what command you used in order to setup the settings in Leo's welcome screen properly. (perhaps you need to specify the python command as "py", "python", "python3" or "python3.11" or "python3.10" depending on what your setup is on your machine. Perhaps your "Leo-Editor" path was wrong. Or perhaps the websockets were installed on another python installation on your machine, different than the one that is used by leointeg when it tries to start the server itself. (in case you have many python installed on your machine, that is...)

(another possibility is websockets not installed properly) 

When installing websockets with 'pip install websockets', make sure you're installing it to the right python installation that you intend to run the server with. (in case you have many python installations on your machine in various folders, like python2, python3. etc. or, with annaconda wich can let people use many different python installations on their machines.)

I've got to go now but i'll try later on my windows machine which also has python 3.11 like you have. In the meantime please try some of the stuff I suggested and (much importantly) take screenshots because often times it helps to spot something that you didn't think of mentionning! 

Thanks again for trying out LeoInteg!! 

Please provide feedback and screenshots so that we can help you out in figuring why it didn't work on you machine! :)

Félix

Israel Hands

unread,
Aug 22, 2023, 10:38:28 AM8/22/23
to leo-editor
Felix - thanks for such a timely and comprehensive reply. I have come back from the future and remembered I labelled the directory with the creation date 7/21 rather than the Leo version number.... sad but true! I have installed the latest version of Leo

Leo 6.7.4
Python 3.11.4, PyQt version 6.5.2
Windows 10 AMD64 (build 10.0.19045) SP0


 and pointed Leointeg at it 

C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\leo
 I left the python command empty as I assumed the 'py' for windows would be fine. 
That didn't work...
I then tried 
C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\leo\core 
as that is where the server script actually lives. 
That didn't work  'can't find the server script'

I tried adding py to the Python command but that didn't work. 


When I run the server script manually I get:


Starting LeoBridge Server 1.0.6 (Launch with -h for help)
Traceback (most recent call last):

  File "C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\leo\core\leoPlugins.py", line 538, in loadOnePluginHelper
    __import__(moduleName)

  File "C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\leo\plugins\livecode.py", line 18, in <module>
    from meta import asttools

  File "C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\meta\__init__.py", line 2, in <module>
    from meta.decompiler.instructions import make_module

  File "C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\meta\decompiler\__init__.py", line 7, in <module>
    from meta.decompiler.instructions import make_module, make_function

  File "C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\meta\decompiler\instructions.py", line 9, in <module>
    from meta.decompiler.control_flow_instructions import CtrlFlowInstructions

  File "C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\meta\decompiler\control_flow_instructions.py", line 15, in <module>
    JUMP_OPS = [opcode.opmap[name] for name in JUMPS]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\IH\AppData\Local\Programs\Python\Python311\Lib\site-packages\meta\decompiler\control_flow_instructions.py", line 15, in <listcomp>
    JUMP_OPS = [opcode.opmap[name] for name in JUMPS]
                ~~~~~~~~~~~~^^^^^^

KeyError: 'POP_JUMP_IF_FALSE'

LeoServer: init leoBridge in  1.1 sec.
LeoBridge started at localhost on port: 32125.
Ctrl+c to break

Having done this I tried connecting from VSCode and got the error websocket closed, code 1006

Hope some of that helps.

Ta like, 

IH

Thomas Passin

unread,
Aug 23, 2023, 9:17:35 AM8/23/23
to leo-editor
I tried running leoserver directly and it worked.  That is, LeoInteg in VSC was able to connect.  I have Leo 6.7.4 installed.  Here is the command I used (on Windows):

py -m leo.core.leoserver

What command did you use to start leoserver.py?

Israel Hands

unread,
Aug 23, 2023, 12:32:47 PM8/23/23
to leo-editor
Hi tbp1 - thanks a lot for stopping by with help!  Having restarted my machine, I ran the command you suggested and despite throwing up all the errors I listed above the server ran and I can connect from VSCode - hey hey!!

LeoServer: init leoBridge in  1.0 sec.

LeoBridge started at localhost on port: 32125.
Ctrl+c to break
server: User Connected, Total: 1, Limit: 1

I've managed to open a file and now am about to dive into editing. Sorry, but I have two more questions...

1 Should I worry about all those error messages listed above - which I also see in my Leo log when I start up the app.

and 

2  Should I work on a copy of a valuable file in case of data loss or should I bash away with confidence?

Thanks again for your help and to Felix for all his magnificent efforts. Leo in VSCode looks like quite an adventure!

ta like,

IH


Thomas Passin

unread,
Aug 23, 2023, 1:11:07 PM8/23/23
to leo-editor
On Wednesday, August 23, 2023 at 12:32:47 PM UTC-4 Israel Hands wrote:
Hi tbp1 - thanks a lot for stopping by with help!  Having restarted my machine, I ran the command you suggested and despite throwing up all the errors I listed above the server ran and I can connect from VSCode - hey hey!!

LeoServer: init leoBridge in  1.0 sec.

LeoBridge started at localhost on port: 32125.
Ctrl+c to break
server: User Connected, Total: 1, Limit: 1

I've managed to open a file and now am about to dive into editing. Sorry, but I have two more questions...

1 Should I worry about all those error messages listed above - which I also see in my Leo log when I start up the app.

I can't help you there - I don't get any error messages, and yours don't convey anything to me.  It sounds like a version mismatch somewhere but between which modules or packages I don't know.  If you can work out from the messages which libraries/packages/modules are involved, you could try updating them with pip.  Make sure you run pip using py -m pip install --upgrade <package> where, of course, <package> is whatever package you want to update.

BTW, if you want to see what pip would do without actually having it do anything, you can add the --dry-run parameter.
 
and 

2  Should I work on a copy of a valuable file in case of data loss or should I bash away with confidence?

Work on a copy or back up first!! If it's valuable, do this whether with Leo, Word, VSC, or what have you.  In this case, with the unresolved error messages, for sure.

Félix

unread,
Aug 23, 2023, 9:01:46 PM8/23/23
to leo-editor
Hi Israel,

To help you figure out what to put in LeoInteg's 'Server Options' I figured I'll show you a better screenshot. Please look at the options I put in Leo-Editor Path, and, the path that was constructed automatically from it below in the 'Leo Log Window'. (the line starting with "Launching server with command".)  as you can see, leointeg automatically adds /leo/core/leoserver.py to the path you provide, so just the base path is needed, not the path continuing up to the server itself. 

Also, i don't know what "-m" does after "py", but since it worked, then perhaps the python command you should put in is "py -m" .

Lastly, if you just start Leo (regular Leo) from a terminal command line, do you see the errors mentioned in your above post? (I personally am complete newbie with regards to Python and python installations and annaconda, pip and all those pythonic concepts... sorry I cant help much with that! I hope someone who's good with python libraries / plugins can help you with that part of the error messages...)

Don't hesitate to ask more questions and provide more info. (screenshots are great because people can spot things outside what you think is the problem)

Félix 

Screenshot from 2023-08-23 20-45-06.png

Thomas Passin

unread,
Aug 24, 2023, 12:42:51 AM8/24/23
to leo-editor
On Wednesday, August 23, 2023 at 9:01:46 PM UTC-4 Félix wrote:
Also, i don't know what "-m" does after "py", but since it worked, then perhaps the python command you should put in is "py -m" .

This is something that everyone should learn.  The -m  flag means to run the parameter as a module.  Pip can be run as a python program but also as a python module.  So py -m pip ...  Basically, any module that will execute when imported can be started this way.  Why invoke a program this way? 

1. You automatically get the right version for the Python executable you are running.  For example, if you have both Python 3.9 and 3.11 installed, a bare py will run the latest install, in this case Python 3.11.  With the -m flag, this executable will look for a "pip" module in its own pythonpath.  OTOH, if you just tried to run pip as a program or script,  you might get the version installed for Python 3.9.  It all depends on how the paths were set up on your system during installation.  Using py -m guarantees getting the right one.

Similarly, running Leo with py -m leo.core.runLeo guarantees you will get the Leo installation that goes with Python3.11 (in this example).  You can invoke other Python installed versions, even Python 2.x versions, with the py launcher by specifying them as command line parameters.

If you set the PYTHONPATH environmental variable, for example to git/leo-editor if you have cloned the Leo distro, its location will come first on the pythonpath and code from that location will be loaded first.  That's how I can run Leo from my clone or from the pip-installed version depending on whether I have set PYTHONPATH.

2. If a program can be run as a module (and is on the pythonpath) you don't need to know where on the disk it's located.  You do need to know the module path, but that's usually easier to find or learn about.  In this case, IH wanted to run leoserver.py, which is in Leo's leo/core directory. This file can be run as a module (you can just try it to see if it works), so we don't have to remember and type its full path, or start from the right directory.  We just type py -m leo.core.leoserver (without the ".py").

For LeoInteg, you don't need to include -m in the startup setting.  You do need to give the "Leo-Editor Path" and it should be the directory immediately under which the "leo" directory exists. For my git clone of Leo, that is C:\Tom\git\leo-editor.  Currently I leave the "Python Command" box empty and everything is working.

Hope this helps someone!

Israel Hands

unread,
Aug 30, 2023, 7:36:12 AM8/30/23
to leo-editor
First apologies for slow reply - been away. Second massive thanks to Felix and Thomas - I'm now well on my way. I was pointing the Leo Editor Path to too deep a directory, this is now working fine. I'm not going to worry about error messages for the moment but instead try and get my head round Leo in VSCode. Thomas I'm reading your note about modules and paths - I feel I need to understand this better to make headway. I have to say I found path setting on the Amiga more intuitive, those were the days.  Again many thanks for taking the time, LeoInteg is a thing of beauty!  IH

Thomas Passin

unread,
Aug 30, 2023, 8:06:42 AM8/30/23
to leo-editor
On Wednesday, August 30, 2023 at 7:36:12 AM UTC-4 Israel Hands wrote:
Thomas I'm reading your note about modules and paths - I feel I need to understand this better to make headway.

The expression to use with the -m flag is the same one you would use to import a module.  In the leoserver example,  you would expect to import the module with import leo.core.leoserver. So that's what you put after the -m on the command line: leo.core.leoserver.  There may be a few exceptions for some more esoteric import constructs, but you probably will never have to worry about them.
 
I have to say I found path setting on the Amiga more intuitive, those were the days. 

Except when we had to type out those sometimes long names of the floppy disk the file was on - remember those? 

Again many thanks for taking the time, LeoInteg is a thing of beauty!  IH

A fantastic job by Felix, isn't it? 

Israel Hands

unread,
Aug 30, 2023, 10:13:56 AM8/30/23
to leo-editor
Hi Thomas, I must have erased those long names on floppy disks from my memory!  I remember the path stuff going in a config file and I remember editing that file with CyngusEd. And yes absolutely, yes - Felix deserves some sort of medal - well a gold medal for his work on this. Just brilliant... as is Leo itself. I've been trying to get my sons on board for ever but one is a hard core C guy and the other uses Jupiter Notebooks. Which I know nothing about, except that it's a big deal in Python world. Anyway thanks again Thomas and keep up the good work!  IH

Thomas Passin

unread,
Aug 30, 2023, 1:37:54 PM8/30/23
to leo-editor
On Wednesday, August 30, 2023 at 10:13:56 AM UTC-4 Israel Hands wrote:
I've been trying to get my sons on board for ever but one is a hard core C guy 

Have you seen Speed Ream's writeup about how his company uses Leo and gets ~30% productivity improvement (C, C++, and assembler)?  It's over 20 years old but still tantalizing -

Félix

unread,
Aug 30, 2023, 9:29:06 PM8/30/23
to leo-editor
Thanks for the kind words to both of you! Really appreciated!!

But hold on to your hats, LeoInteg is insignificant compared to LeoJS!  (Coming soon!)

Félix

Edward K. Ream

unread,
Aug 31, 2023, 6:17:44 AM8/31/23
to leo-editor
On Wednesday, August 30, 2023 at 8:29:06 PM UTC-5 Félix wrote:

But hold on to your hats, LeoInteg is insignificant compared to LeoJS!  (Coming soon!)

That's great news!

Do you want to include the completed 6.7.5 items in the first release of leoJS? It's totally up to you. Otoh, the new python importer is way cool, hehe.

And another question. I'm considering releasing 6.7.5 in about two weeks. All the remaining open items are on hold until after leoJS. What do you think?

Edward

Félix

unread,
Aug 31, 2023, 10:11:37 PM8/31/23
to leo-editor
Edward, 

This sounds good. I'll incorporate the latest completed items of 6.7.5 in leojs no problem at all  - I think I already did a few actually :) 

Also, I have no problem with a release of  6.7.5 in the time frame that you suggested. 

Félix

Edward K. Ream

unread,
Sep 1, 2023, 7:46:12 AM9/1/23
to leo-e...@googlegroups.com
On Thu, Aug 31, 2023 at 9:11 PM Félix <felix...@gmail.com> wrote:

I have no problem with a release of  6.7.5 in the time frame that you suggested.

Excellent. I've the moved four "waiting" items to 6.7.6, still due in November.

I'll fix the new quirps you just reported for 6.7.5 soon. Keep them coming :-)

Edward
Reply all
Reply to author
Forward
0 new messages