dpo / atom-python-debugger

IDE-like Python debugger for Atom
MIT License
42 stars 13 forks source link

Uncaught Error: spawn UNKNOWN #4

Closed darkgrunge closed 8 years ago

darkgrunge commented 8 years ago

Hi,

Just installed the package and I am trying to run it with a python script. I am getting the following error when trying to run it.

I am running Atom on Windows 7

internal/child_process.js:298 Error: spawn UNKNOWN at exports._errnoException (util.js:837:11) at ChildProcess.spawn (internal/child_process.js:298:11) at exports.spawn (child_process.js:351:9) at PythonDebuggerView.module.exports.PythonDebuggerView.runBackendDebugger (file:///C:/Users/andrei.capraru/.atom/packages/python-debugger/lib/python-debugger-view.coffee:110:24) at PythonDebuggerView.module.exports.PythonDebuggerView.runApp (file:///C:/Users/andrei.capraru/.atom/packages/python-debugger/lib/python-debugger-view.coffee:79:6) at HTMLButtonElement. (C:\Users\andrei.capraru\AppData\Local\atom\app-1.5.4\resources\app.asar\node_modules\atom-space-pen-views\node_modules\space-pen\lib\space-pen.js:220:36) at HTMLButtonElement.jQuery.event.dispatch (C:\Users\andrei.capraru\AppData\Local\atom\app-1.5.4\resources\app.asar\node_modules\jquery\dist\jquery.js:4435:9) at HTMLButtonElement.elemData.handle (C:\Users\andrei.capraru\AppData\Local\atom\app-1.5.4\resources\app.asar\node_modules\jquery\dist\jquery.js:4121:28)

dpo commented 8 years ago

Thanks for the report. I don't have a Windows machine handy unfortunately, but we'll try and resolve the issue. In a terminal, could you check that you are able to run

C:/Users/andrei.capraru/.atom/packages/python-debugger/resources/atom_pdb.py your_script.py
darkgrunge commented 8 years ago

Getting the following error. This is popping out near the end.

-> a = [1,2,3] Traceback (most recent call last): File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_pdb.py", line 55, in main apdb._runscript(script) File "C:\Python34\lib\pdb.py", line 1542, in _runscript self.run(statement) File "C:\Python34\lib\bdb.py", line 431, in run exec(cmd, globals, locals) File "", line 1, in File "c:\users\andrei.capraru.atom\packages\python-debugger\resources\test1.py", line 1, in a = [1,2,3] File "c:\users\andrei.capraru.atom\packages\python-debugger\resources\test1.py", line 1, in a = [1,2,3] File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch return self.dispatch_line(frame) File "C:\Python34\lib\bdb.py", line 66, in dispatch_line self.user_line(frame) File "C:\Python34\lib\pdb.py", line 259, in user_line self.interaction(frame, None) File "C:\Python34\lib\pdb.py", line 346, in interaction self._cmdloop() File "C:\Python34\lib\pdb.py", line 319, in _cmdloop self.cmdloop() File "C:\Python34\lib\cmd.py", line 105, in cmdloop self.preloop() File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_pdb.py", line 33, in preloop self.do_locate(1) File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_pdb.py", line 30, in do_locate print >> self.stdout, "file::", filename, "\nline::", lineno TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper' Traceback (most recent call last): File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_pdb.py", line 55, in main apdb._runscript(script) File "C:\Python34\lib\pdb.py", line 1542, in _runscript self.run(statement) File "C:\Python34\lib\bdb.py", line 431, in run exec(cmd, globals, locals) File "", line 1, in File "c:\users\andrei.capraru.atom\packages\python-debugger\resources\test1y", line 1, in a = [1,2,3] File "c:\users\andrei.capraru.atom\packages\python-debugger\resources\test1y", line 1, in a = [1,2,3] File "C:\Python34\lib\bdb.py", line 48, in trace_dispatch return self.dispatch_line(frame) File "C:\Python34\lib\bdb.py", line 66, in dispatch_line self.user_line(frame) File "C:\Python34\lib\pdb.py", line 259, in user_line self.interaction(frame, None) File "C:\Python34\lib\pdb.py", line 346, in interaction self._cmdloop() File "C:\Python34\lib\pdb.py", line 319, in _cmdloop self.cmdloop() File "C:\Python34\lib\cmd.py", line 105, in cmdloop self.preloop() File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_b.py", line 33, in preloop self.do_locate(1) File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_b.py", line 30, in do_locate print >> self.stdout, "file::", filename, "\nline::", lineno TypeError: unsupported operand type(s) for>>: 'builtin_function_or_method' an '_io.TextIOWrapper'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_pdb.py", line 75, in atom_pdb.main() File "C:\Users\andrei.capraru.atom\packages\python-debugger\resources\atom_pdb.py", line 66, in main print >> sys.stdout, "Uncaught exception ", type(inst), " ... entering post-mortem debugging" TypeError: unsupported operand type(s) for >>: 'builtin_function_or_method' and '_io.TextIOWrapper'

dpo commented 8 years ago

I think the reason is that the debugger is only for Python2 at the moment. It's not very hard to generalize it to Python3. I'll add a label to this issue that indicates it's Python3-related. Either I'll get to it in the coming days or perhaps someone will send a PR.

marcos-alfredo commented 8 years ago

I am having the same problem as originally reported, on Win7 running python 2.7. The debugger works fine if I run it from the terminal, as asked above.

dpo commented 8 years ago

Thanks for the report. Are you also using Python3? I'll look into it.

dpo commented 8 years ago

@marcos-alfredo could you provide a link to the traceback you get?

marcos-alfredo commented 8 years ago

[Enter steps to reproduce below:]

  1. Inserted a breakpoint
  2. Toggled view
  3. Pressed run

Atom Version: 1.5.4 System: Microsoft Windows 7 Professional Thrown From: python-debugger package, v0.0.2

Stack Trace

Uncaught Error: spawn UNKNOWN

At internal/child_process.js:298

Error: spawn UNKNOWN
    at exports._errnoException (util.js:837:11)
    at ChildProcess.spawn (internal/child_process.js:298:11)
    at exports.spawn (child_process.js:351:9)
    at PythonDebuggerView.module.exports.PythonDebuggerView.runBackendDebugger (file:///C:/Users/mpinto/.atom/packages/python-debugger/lib/python-debugger-view.coffee:110:24)
    at PythonDebuggerView.module.exports.PythonDebuggerView.runApp (file:///C:/Users/mpinto/.atom/packages/python-debugger/lib/python-debugger-view.coffee:79:6)
    at HTMLButtonElement.<anonymous> (C:\Users\mpinto\AppData\Local\atom\app-1.5.4\resources\app.asar\node_modules\atom-space-pen-views\node_modules\space-pen\lib\space-pen.js:220:36)
    at HTMLButtonElement.jQuery.event.dispatch (C:\Users\mpinto\AppData\Local\atom\app-1.5.4\resources\app.asar\node_modules\jquery\dist\jquery.js:4435:9)
    at HTMLButtonElement.elemData.handle (C:\Users\mpinto\AppData\Local\atom\app-1.5.4\resources\app.asar\node_modules\jquery\dist\jquery.js:4121:28)

Commands

     -5:59.1.0 python-nosetests:run (atom-text-editor.editor.is-focused)
     -5:12.6.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -5:12.6.0 core:cancel (atom-text-editor.editor.is-focused)
     -5:11.7.0 editor:consolidate-selections (atom-text-editor.editor.is-focused)
     -5:11.7.0 core:cancel (atom-text-editor.editor.is-focused)
     -5:05.4.0 python-nosetests:hide (atom-text-editor.editor.is-focused)
     -4:41.4.0 python-nosetests:run (atom-text-editor.editor.is-focused)
     -2:57.4.0 python-nosetests:hide (atom-text-editor.editor.is-focused)
     -0:49.2.0 python-debugger:breakpoint (atom-text-editor.editor.is-focused)
     -0:47.5.0 python-debugger:toggle (atom-text-editor.editor.is-focused)

Config

{
  "core": {}
}

Installed Packages

# User
double-click-tree-view, v1.1.0
language-python, v0.43.0
linter, v1.11.3
linter-flake8, v1.13.0
python-debugger, v0.0.2
python-nosetests, v0.2.0

# Dev
No dev packages
dpo commented 8 years ago

Thanks. Are you trying to run the debugger to debug a test that fails?

marcos-alfredo commented 8 years ago

Any script.

If I create a new file with just a print statement it still fails.

dpo commented 8 years ago

@darkgrunge Would you mind trying the py3k branch and let me know if it resolves your issue?

dpo commented 8 years ago

@marcos-alfredo It seems it could be an interaction with python-nosetests. If that's a possibility for you, could you temporarily deactivate python-nosetest, restart Atom, and let me know if you're still seeing the problem?

marcos-alfredo commented 8 years ago

@dpo Sorry for the delay. Disabling python-nosetests had no effect on the issue.

dpo commented 8 years ago

@marcos-alfredo Thanks. Is the debugger file executable in your case? I'm not sure how to make it executable on Windows. On Unix systems, we do chmod +x /path/to/atom_pdb.py.

Huxlyx commented 8 years ago

Hi there! I have the same problem with Windows 10. I tried the py3k branch which also didn't work but gave me an ENOENT error and a message that the file could not be found or is not on my path (debugger file is executable). Then i tried to put a static path to the atom_pdb.py file in the python-debugger-view.coffee skript - same error. Finally I wrote a small "hello world" c++ program, compiled it to an .exe and tried to spawn that... which worked o_O. So could it be, that it's not possible to spawn files that are not .exe files on windows?

dpo commented 8 years ago

@Huxlyx Thanks for the additional info. I'm wondering if on Windows, it would be safer to spawn Python with the debugger as argument instead of spawning the debugger as an executable. How do you call Python from the command line on your machine? Is it just python?

Huxlyx commented 8 years ago

Yes, that's correct.

dpo commented 8 years ago

I just pushed the python_exe branch. There's an option now to select the Python executable you'd like to use. By default, it's python, so it should "just work". Now I spawn Python instead of the debugger script. Let me know if that works better for you.

KeithCu commented 8 years ago

I'm seeing this on Arch Linux also (which uses Python 3 by default)

dpo commented 8 years ago

@KeithCu Did you try the py3k branch?

KeithCu commented 8 years ago

No, is there a way to specify the branch via apm install? I'm kinda new to Atom.

dpo commented 8 years ago

Something like

mkdir ~/github
cd ~/github
git clone https://github.com/dpo/atom-python-debugger.git
cd atom-python-debugger
git checkout py3k
apm install
apm link
KeithCu commented 8 years ago

Okay, I uninstalled the official package did the manual install and it works. Thanks! Good luck getting this into the official package soon.

Huxlyx commented 8 years ago

@dpo the python_exe branch works great! Either with or without a path set in the settings.

dpo commented 8 years ago

Excellent. I'll push a new release later today. Thanks all for the investigative work!