Running Python 3 from Light Table
Asked Answered
H

4

6

I am trying Light Table and learning how to use it. Overall, I like it, but I noticed that the only means of making the watches and inline evaluation work in Python programs uses Python 2.7.8, making it incompatible with some of my code. Is there a way to make it use Python 3 instead?

I looked on Google and GitHub and I couldn't find anything promising.

I am using a Mac with OS X 10.10.2. I have an installation of Python 3.4.0 that runs fine from the Terminal.

Herring answered 4/2, 2015 at 17:36 Comment(0)
C
3

I had the same problem with using a syntax that was only valid on Python3.3. - Go to Settings:User Behaviour - add the line (find the real path of your python binary): [:app :lt.plugins.python/python-exe "/usr/bin/python3.4"] - Save and test in your lighttable

It worked for me :) Hope it helps

Cooksey answered 9/4, 2015 at 9:38 Comment(1)
It worked. Thank you. Here is the line I added, for everyone's reference: [:app :lt.plugins.python/python-exe "/Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4"]Herring
A
0

Hit Ctrl + Space to bring up the control pane. Then start typing Set Syntax and select Set Syntax to Python. Start typing your Python then press Ctrl + Shift + Enter to build and run the program.

Aldas answered 4/2, 2015 at 17:44 Comment(6)
I hit Ctrl + Space. I typed Python in the search box in the sidebar that showed on the right side and there were no results.Herring
Then start typing Set SyntaxAldas
I hit Ctrl + Space and typed Set Syntax. The one match that came up said "Editor: Set current editor syntax". I clicked on that and it gave me a bunch of choices. The only one that looked relevant was "Python". I picked that and nothing seemed to happen. I typed import sys; sys.version into the editor and tried evaluating the sys.version. It came back as 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)], just like it did before.Herring
So that means you haven't added Python 3 to your system path.Aldas
What do you mean by that? If I type echo $PATH in the Terminal, I see a bunch of directories including /Library/Frameworks/Python.framework/Versions/3.4/bin. Do I need to do anything else?Herring
Perhaps, Light Table doesn't support Python 3.Aldas
C
0

I got the same problem. It worked for me after saving the file with a .py extension and then typing Cmd+Enter.

Copra answered 4/2, 2015 at 21:22 Comment(2)
I typed import sys; sys.version, saved it in a file with a .py extension, selected the sys.version, pressed Cmd + Enter, and it showed 2.7.8 (v2.7.8:ee879c0ffa11, Jun 29 2014, 21:07:35) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)].Herring
It worked only because it use the 2.7 python. Cannot use Python 3 without solving the Unicode issue see my answerJump
J
0

Besides changing Ctrl+Space Settings:User Behaviour

 [:app :lt.plugins.python/python-exe "/path_to_your_custom_bin/bin/python3.4"]

There is an issue with Unicode ( 'unicode' is not defined), and I also needed to modify ltmain.py to work with Python3 see here:

https://github.com/eduardflorinescu/lighttable_python3_patch/blob/master/ltmain.py

Make sure you backup the orginal ltmain.py, you can diff the two to see what are the differences and what was changed:

Jump answered 11/4, 2018 at 10:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.