Documentation - Running Leo

69 views
Skip to first unread message

lewis

unread,
Dec 28, 2016, 9:08:21 PM12/28/16
to leo-editor
In the Leo documentation at http://leoeditor.com/running.html the first line of the sub-heading says:

You can run Leo from a Python interpreter as follows:

import leo
leo.run() # runs Leo, opening a new outline or,
leo.run(fileName=aFileName) # runs Leo, opening the given file name.


Is this an old legacy option? If so it should be moved from the beginning to the end of the Running Leo documentation.
This will improve the focus for new users of Linux/Windows and not distract them with esoteric python options.
Why would someone want to run Leo this way? If there is a good reason may I suggest adding "You may want to use this method if ......."

Hope the suggestions are helpful.

Regards
Lewis

lewis

unread,
Dec 28, 2016, 9:23:56 PM12/28/16
to leo-editor
This doesn't work for me on win10 py2.7.13 or win vista python 3.5.2 if I run in a python interpreter (Idle)

>>> import leo

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import leo
ImportError: No module named leo
>>>

I may be misunderstanding something.

Regards
Lewis

Edward K. Ream

unread,
Dec 29, 2016, 5:03:44 AM12/29/16
to leo-editor
On Wed, Dec 28, 2016 at 9:08 PM, lewis <lewi...@operamail.com> wrote:
In the Leo documentation at http://leoeditor.com/running.html the first line of the sub-heading says:

You can run Leo from a Python interpreter as follows:

import leo
leo.run() # runs Leo, opening a new outline or,
leo.run(fileName=aFileName) # runs Leo, opening the given file name.


Is this an old legacy option?

​It works for me. You may have to add the leo folder to Python's path.

Edward

lewis

unread,
Dec 30, 2016, 5:07:26 PM12/30/16
to leo-editor
OK thanks, added Pythonpath with variable values as my Leo folder.
The import leo command works fine. But I get a traceback with leo.run() :

Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import leo
>>> leo.run()
Traceback (most recent call last):
  File "N:\git\leo-editor\leo\core\leoApp.py", line 1193, in setLeoID
    g.red('leoID=', g.app.leoID, ' (in ', theDir, ')', spaces=False)
  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 5057, in red
    g.es_print(color=g.actualColor('red'), *args, **keys)
  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 5200, in es_print
    g.pr(*args, **keys)
  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 5326, in pr
    stdout.write(s2)
AttributeError: 'NoneType' object has no attribute 'write'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    leo.run()
  File "N:\git\leo-editor\leo\__init__.py", line 11, in run
    runLeo.run(*args,**keys)
  File "N:\git\leo-editor\leo\core\runLeo.py", line 63, in run
    g.app.loadManager.load(fileName, pymacs)
  File "N:\git\leo-editor\leo\core\leoApp.py", line 1966, in load
    lm.doPrePluginsInit(fileName, pymacs)
  File "N:\git\leo-editor\leo\core\leoApp.py", line 2016, in doPrePluginsInit
    lm.initApp(verbose)
  File "N:\git\leo-editor\leo\core\leoApp.py", line 2118, in initApp
    g.app.setLeoID(verbose=verbose)
  File "N:\git\leo-editor\leo\core\leoApp.py", line 1201, in setLeoID
    g.error('unexpected exception in app.setLeoID')
  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 5051, in error
    g.es_print(color=g.actualColor('red'), *args, **keys)
  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 5200, in es_print
    g.pr(*args, **keys)
  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 5326, in pr
    stdout.write(s2)
AttributeError: 'NoneType' object has no attribute 'write'
>>> 


Leo Log Window
Leo 5.4, build 20161226191821, Mon Dec 26 19:18:21 CST 2016
Git repo info: branch = master, commit = 0cf49992c997
Python 3.5.2, PyQt version 5.6.0
Windows Vista x86 (build 6.0.6002) SP2

Regards
Lewis

Edward K. Ream

unread,
Dec 31, 2016, 7:13:17 AM12/31/16
to leo-editor
On Fri, Dec 30, 2016 at 5:07 PM, lewis <lewi...@operamail.com> wrote:
OK thanks, added Pythonpath with variable values as my Leo folder.
The import leo command works fine. But I get a traceback with leo.run() :
​...​

  File "N:\git\leo-editor\leo\core\leoGlobals.py", line 5326, in pr
    stdout.write(s2)
AttributeError: 'NoneType' object has no attribute 'write'

​A strange one.  It works for me.

Rev 187ac6c attempts a fix.  Does it work for you?

Edward

lewis

unread,
Dec 31, 2016, 7:47:40 AM12/31/16
to leo-editor
Not working for me. Traceback is identical.

lewis

unread,
Dec 31, 2016, 8:01:07 AM12/31/16
to leo-editor
I also updated a laptop - added Pythonpath with variable values as my Leo folder.
It had the same traceback, but I haven't tried the 187ac6c commit as yet.

lewis

unread,
Dec 31, 2016, 4:47:50 PM12/31/16
to leo-editor
Same traceback on the laptop running commit = c84488a74ea5
Python 3.5.2, PyQt version 5.7.1

lewis

unread,
Jan 10, 2017, 6:48:59 AM1/10/17
to leo-e...@googlegroups.com
Hi Edward,

I realised I was running the Python 3.6 IDLE interactive environment, which caused the errors.
Running the Python 3.6 interpreter works exactly as the Leo docs describe :)
Apologies for missing that important detail. Hope your fix hasn't caused any issues.

Regards
Lewis

Edward K. Ream

unread,
Jan 10, 2017, 9:28:29 AM1/10/17
to leo-editor
On Tue, Jan 10, 2017 at 6:48 AM, lewis <lewi...@operamail.com> wrote:

I realized I was running the Python 3.6 IDLE interactive environment, which caused the errors.
​n​
Running the Python 3.6 interpreter works exactly as the Leo docs describe :)

​Glad to hear it.

Edward
Reply all
Reply to author
Forward
0 new messages