LightTable / Python

Python language plugin for Light Table
MIT License
98 stars 51 forks source link

Windows 7 Error: Can't open file py-src\ltmain.py #16

Closed tpgit closed 10 years ago

tpgit commented 10 years ago

My user name on Windows 7 has a space char in it. When I attempt to evaluate a python statement I get the following error:

  python: can't open file '"C:\Users\<user name>\AppData\Local\LightTable\plugins\Python\py-src\ltmain.py"': [Errno 22] Invalid argument

On Windows 7, calls to proc/exec should not wrap the args in quotes. In this case remove call to escape-spaces from https://github.com/LightTable/Python/blob/master/src/lt/plugins/python.cljs#L89

See Windows 7 "can't open file py-src\ltmain.py" error for details on why wrapping args in proc/exec calls is a bad idea even on Windows.

gpiancastelli commented 10 years ago

Same error here, on Windows Vista. However, the ltmain.py that LightTable tries to open is on a path without spaces in it.

I confirm that the solution proposed by @tpgit works.

pywkm commented 10 years ago

I have same error, Windows 7, no spaces in path. And solution proposed by @tpgit does not work. :-(

tpgit commented 10 years ago

I perhaps should have mentioned that you need to re-compile python.cljs? So either build the entire plugin or just eval something in python.cljs (like run-py).

pywkm commented 10 years ago

Sorry, I don't even know what does it mean (recompile python.cljs). Pressing ctrl+enter in python.cljs results with message: """ No client available.

We don't know what kind of client you want for this one. Try starting a client by choosing one of the connection types in the connect panel. """

I just wanted to run python scripts in LT. I don't know Clojure. Maybe I'll return to LT when this issue would be fixed (officially). I'm going back to PyCharm now...

tpgit commented 10 years ago

I believe this means you should add a connection to Light Table UI (so it can display the results of the eval).

Alternatively, without LT running, using the Command Prompt window, you could navigate to the root of the Python plugin, either \plugins\python or C:\Users\AppData\Local\LightTable\plugins\Python\ (the directory with a project.clj file in it) and run:

lein cljsbuild once

That should result in a newly modified python_compiled.js (and python_compiled.js.map) file.

gpiancastelli commented 10 years ago

@pywkm I do not know Clojure, too. I just removed the call to escape_spaces in the compiled version of the plugin, that you can find at %LIGHT_TABLE_INSTALL_DIR%\plugins\python\python_compiled.js.

On line 96, you find this:

lt.plugins.python.escape_spaces.call(null,lt.plugins.python.py_path)

Just replace it with:

lt.plugins.python.py_path

And you should good to go. Quite the hacky way of doing it, I know, but it worked.

Muhd commented 10 years ago

gpiancastelli's fix worked for me.

fstamour commented 10 years ago

gpiancastelli's fix worked for me too :+1:

mona24 commented 10 years ago

i still haven't understood how and where exactly to find the plugin function mentioned by gpiancastelli. btw mine is windows xp.

gpiancastelli commented 10 years ago

@mona24 you have installed LightTable in a directory somewhere, don't you. Go into that directory. That directory should contain a plugins directory. Go into that. There, you should find a directory called python. Go into that. There, you should find a file called python_compiled.js.

Open python_compiled.js with a text editor. Go to line 96.

On that line, you should find the following text:

lt.plugins.python.escape_spaces.call(null,lt.plugins.python.py_path)

Replace it with the following text:

lt.plugins.python.py_path

Start or restart LightTable, and you should be able to evaluate Python statement and programs from within it.

mona24 commented 10 years ago

i'm really really sorry. it still didn't work.

i opened python_compiled.js with notepad and edited it as you told. i'm still getting the same error.

btw in the line that you mentioned the following text was there: (not exactly as above)

lt.plugins.python.escape_spaces = (function escape_spaces(s){if(cljs.core.EQ.call(null,lt.objs.files.separator,"\")) {return [cljs.core.str("\""),cljs.core.str(s),cljs.core.str("\"")].join(''); } else {return s; } });

On Sat, Jun 14, 2014 at 8:56 PM, Giulio Piancastelli < notifications@github.com> wrote:

@mona24 https://github.com/mona24 you have installed LightTable in a directory somewhere, don't you. Go into that directory. That directory should contain a plugins directory. Go into that. There, you should find a directory called python. Go into that. There, you should find a file called python_compiled.js.

Open python_compiled.js with a text editor. Go to line 96.

On that line, you should find the following text:

lt.plugins.python.escape_spaces.call(null,lt.plugins.python.py_path)

Replace it with the following text:

lt.plugins.python.py_path

Start or restart LightTable, and you should be able to evaluate Python statement and programs from within it.

— Reply to this email directly or view it on GitHub https://github.com/LightTable/Python/issues/16#issuecomment-46090860.

gpiancastelli commented 10 years ago

@mona24 that's weird. I have that assignment on line 80.

However. Forget line numbers. Just search the file for the text I said you would find on line 96. Then replace it with the other text. Save the file. Run LightTable.

Oh, you should also forget about Notepad, too.

ibdknox commented 10 years ago

This is now fixed in the 0.0.5 version of the python plugin. You can update from the plugin manager :)

mona24 commented 10 years ago

Thank you so much :)

puneet-ibm commented 10 years ago

gpiancastelli's fix works.