Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

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

Closed
tpgit opened this issue May 8, 2014 · 15 comments
Closed

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

tpgit opened this issue May 8, 2014 · 15 comments

Comments

@tpgit
Copy link

tpgit commented May 8, 2014

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
Copy link

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
Copy link

pywkm commented Jun 4, 2014

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

@tpgit
Copy link
Author

tpgit commented Jun 4, 2014

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
Copy link

pywkm commented Jun 4, 2014

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
Copy link
Author

tpgit commented Jun 4, 2014

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
Copy link

@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
Copy link

Muhd commented Jun 6, 2014

gpiancastelli's fix worked for me.

@fstamour
Copy link

gpiancastelli's fix worked for me too 👍

@mona24
Copy link

mona24 commented Jun 14, 2014

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

@gpiancastelli
Copy link

@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
Copy link

mona24 commented Jun 17, 2014

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 <
[email protected]> 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
#16 (comment).

@gpiancastelli
Copy link

@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
Copy link
Member

ibdknox commented Jun 18, 2014

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

@mona24
Copy link

mona24 commented Jun 18, 2014

Thank you so much :)

@puneet-ibm
Copy link

gpiancastelli's fix works.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants