-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use SublimeText Build Systems for dubugging #27
Comments
Not yet. It's the second time it's requested, so I will implement it when I can. |
As a work around, you can substitute the string "python2" by "python3.5" (or full path) in the DBPython2 file, and from then on use the Python 2 debugger in sublime (which will use your interpreter). This is not guaranteed to work |
Thanks for offering the workaround. Unfortunately, it does not work for me. That's what I get when I try to enter debug:
And that's when I try to add a breakpoint:
Am I missing anything? Do I have to install some package into the virtual environment? |
If after changing the string, you closed and re started sublime (which you should do), then I don't know. The traceback is not very informative. I'll have to analyze and try the problem myself |
I've restarted it several times. To no avail. Today I've tried to start out-of-the-box Python2 debugger on another machine. And it failed with the following error:
Python 3 debugger (with default |
I've also got this in the console:
Not sure if all of that is related to Python Debugger... |
And yes, yaraslau@dell:~ $ echo $PATH
/home/yaraslau/bin:/home/yaraslau/.local/bin:/home/yaraslau/bin:/home/yaraslau/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
yaraslau@dell:~ $ which python2
/usr/bin/python2
yaraslau@dell:~ $ python2
Python 2.7.13 (default, Nov 23 2017, 15:37:09)
[GCC 6.3.0 20170406] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> As well as yaraslau@dell:~ $ which python3
/usr/bin/python3
yaraslau@dell:~ $ which python3.5
/usr/bin/python3.5
yaraslau@dell:~ $ python3
Python 3.5.3 (default, Nov 23 2017, 11:34:05)
[GCC 6.3.0 20170406] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> |
Yes, it is related with Python debugger. I think what is happening is that dbPython2 isn't successfully launching the process running the debugger. Which in your case would be running python3.5, if you changed the string. If the string is "python3.5", my guess is that the python2 debugger backend code is incompatible with python3. If the string is "python2", I don't know what is happening. The following is something I do when debugging the plug in, it takes some work. The backend doesn't print error messages in sublime because it runs in a different process. We want to see them. So, instead of letting the plug in launch the process, we'll launch it ourselves in a terminal. In dbPython2 comment the line which launches the process (the one containing Then, before starting sublime, launch the debugger process yourself in a terminal (find out the command by reading the arguments passed to popen that you just commented out) Open sublime, and at some point, we will get our desired error in the terminal. |
I started When I started Sublime Text and switched to Python 2 I got the following output into the ST console: fully connected
language: Python2
mydb2.py started
debugger ready
('connecting', 5004)
('connected', ('127.0.0.1', 54826))
('connecting', 5005)
('connected', ('127.0.0.1', 34426))
parent ready Then I tried adding a breakpoint. Sublime Text: Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 797, in run_
return self.run()
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 123, in run
toggle_breakGUI(filename, line)
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 158, in toggle_breakGUI
bps.pop(line) if line in bps else bps.update({line: {}})
File "./python3.3/contextlib.py", line 55, in __exit__
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 136, in bp_manager
V.add_regions("bp", [get_line(V, l - 1) for l in bps], *style)
AttributeError: 'NoneType' object has no attribute 'add_regions'
Then I tried entering debug. Sublime Text started working as expected stepping through code. Started Debugging
{'bytearray': <type 'bytearray'>, 'IndexError': <type 'exceptions.IndexError'>, 'all': <built-in function all>, 'help': Type help() for interactive help, or help(object) for help about object., 'vars': <built-in function vars>, 'SyntaxError': <type 'exceptions.SyntaxError'>, 'unicode': <type 'unicode'>, 'UnicodeDecodeError': <type 'exceptions.UnicodeDecodeError'>, 'memoryview': <type 'memoryview'>, 'isinstance': <built-in function isinstance>, 'copyright': Copyright (c) 2001-2017 Python Software Foundation.
All Rights Reserved.
...
--line--
('break at', '/home/yaraslau/test_project/loop.py', 1, 'in', '<module>')
--line--
('break at', '/home/yaraslau/test_project/loop.py', 3, 'in', '<module>')
--line--
('break at', '/home/yaraslau/test_project/loop.py', 4, 'in', '<module>')
--line--
('break at', '/home/yaraslau/test_project/loop.py', 7, 'in', '<module>')
--line--
('break at', '/home/yaraslau/test_project/loop.py', 11, 'in', '<module>')
--line--
('break at', '/home/yaraslau/test_project/loop.py', 22, 'in', '<module>')
--line--
('break at', '/home/yaraslau/test_project/loop.py', 37, 'in', '<module>')
1000
--line--
('break at', '/home/yaraslau/test_project/loop.py', 38, 'in', '<module>') But, as you can get, there were no breakpoints 'cause they initially failed to be set. Then I stopped debugging with Upon closing Sublime Text I've got the following error from Traceback (most recent call last):
File "/home/yaraslau/Dropbox/sys/dot.config/sublime-text-3/Packages/Python Debugger/backends/comm_u
tils.py", line 80, in loop
while True: self()
File "/home/yaraslau/Dropbox/sys/dot.config/sublime-text-3/Packages/Python Debugger/backends/comm_u
tils.py", line 76, in __call__
ans = self[msg]
File "/home/yaraslau/Dropbox/sys/dot.config/sublime-text-3/Packages/Python Debugger/backends/comm_u
tils.py", line 66, in __getitem__
instruction, parameters , _ = m.split('$@#')
ValueError: need more than 1 value to unpack
('connection down', ValueError('need more than 1 value to unpack',)) I've decided to repeat the experiment and just switch back to Python 3 in Sublime Text instead of quitting it. There were no errors: language: Python3 But when I tried switching to Python 2 again I got the following error in Sublime Text console: Traceback (most recent call last):
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/comm_utils.py", line 80, in loop
while True: self()
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/comm_utils.py", line 75, in __call__
msg = recv_message(self.client_conn)
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/comm_utils.py", line 47, in recv_message
message = conn.recv(BUFFER_SIZE).decode("UTF-8")
OSError: [Errno 107] Transport endpoint is not connected
connection down [Errno 107] Transport endpoint is not connected
Closing Sublime Text produced the same |
Next, I tried the same scenario but with my virtualenv's Expectedly got the following 2to3 related error: File "dbpy2_server.py", line 7
print "mydb2.py started"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("mydb2.py started")? Modified all mydb2.py started
debugger ready
connecting 5004 N.B.: I managed to connect to it by switching to Python 2 in Sublime Text. Tried setting breakpoints. But they silently failed without any output to either Sublime Text or Then I tried entering debug mode. Closing Sublime Text resulted in the same Traceback (most recent call last):
File "/home/yaraslau/Dropbox/sys/dot.config/sublime-text-3/Packages/Python Debugger/backends/comm_utils.py", line 80, in loop
while True: self()
File "/home/yaraslau/Dropbox/sys/dot.config/sublime-text-3/Packages/Python Debugger/backends/comm_utils.py", line 76, in __call__
ans = self[msg]
File "/home/yaraslau/Dropbox/sys/dot.config/sublime-text-3/Packages/Python Debugger/backends/comm_utils.py", line 66, in __getitem__
instruction, parameters , _ = m.split('$@#')
ValueError: not enough values to unpack (expected 3, got 1)
connection down not enough values to unpack (expected 3, got 1) |
So there are definitely some errors:
|
See if the latest commit solves the problem. There is a settings file now, where you can set your interpreter |
Python 3 (Sublime built-in)
Started Debugging
--line--
break at /home/yaraslau/test_project/json-logic.py 1 in <module>
Traceback (most recent call last):
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 176, in runscript
self.run(statement)
File "./python3.3/bdb.py", line 405, in run
File "<string>", line 1, in <module>
File "/home/yaraslau/test_project/json-logic.py", line 1, in <module>
from json_logic import jsonLogic
File "/home/yaraslau/test_project/json-logic.py", line 1, in <module>
from json_logic import jsonLogic
File "./python3.3/bdb.py", line 47, in trace_dispatch
File "./python3.3/bdb.py", line 65, in dispatch_line
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 50, in user_line
self.wait_cmd(frame) # continue to next breakpoint
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 72, in wait_cmd
cmd = self.parent.get_cmd(line(frame),ls,gs, filename(frame))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 69, in get_cmd
refresh_expressions()
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 297, in refresh_expressions
expressions = get_keys(get_view_content("Expression"))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 303, in get_keys
keys = [l.split(' ┃ ')[0].strip() for l in txt.split('\n')]
AttributeError: 'NoneType' object has no attribute 'split'
Uncaught exception. Entering post mortem debugging
Exception in thread Thread-10:
Traceback (most recent call last):
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 176, in runscript
self.run(statement)
File "./python3.3/bdb.py", line 405, in run
File "<string>", line 1, in <module>
File "/home/yaraslau/test_project/json-logic.py", line 1, in <module>
from json_logic import jsonLogic
File "/home/yaraslau/test_project/json-logic.py", line 1, in <module>
from json_logic import jsonLogic
File "./python3.3/bdb.py", line 47, in trace_dispatch
File "./python3.3/bdb.py", line 65, in dispatch_line
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 50, in user_line
self.wait_cmd(frame) # continue to next breakpoint
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 72, in wait_cmd
cmd = self.parent.get_cmd(line(frame),ls,gs, filename(frame))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 69, in get_cmd
refresh_expressions()
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 297, in refresh_expressions
expressions = get_keys(get_view_content("Expression"))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 303, in get_keys
keys = [l.split(' ┃ ')[0].strip() for l in txt.split('\n')]
AttributeError: 'NoneType' object has no attribute 'split'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./python3.3/threading.py", line 901, in _bootstrap_inner
File "./python3.3/threading.py", line 1142, in run
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 48, in <lambda>
threading.Timer(.2, lambda: DB.runscript(filename)).start()
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 187, in runscript
self.wait_cmd(self.stack[self.curidx][0])
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3S.py", line 72, in wait_cmd
cmd = self.parent.get_cmd(line(frame),ls,gs, filename(frame))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 69, in get_cmd
refresh_expressions()
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 297, in refresh_expressions
expressions = get_keys(get_view_content("Expression"))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 303, in get_keys
keys = [l.split(' ┃ ')[0].strip() for l in txt.split('\n')]
AttributeError: 'NoneType' object has no attribute 'split'
Started Debugging
--line--
break at /home/yaraslau/test_project/json-logic.py 1 in <module>
--exception--
exception in <module> (<class 'ImportError'>, ImportError("No module named 'json_logic'",), <traceback object at 0x7fe2a11b1098>)
--return--
return from <module> None
--exception--
exception in <module> (<class 'ImportError'>, ImportError("No module named 'json_logic'",), <traceback object at 0x7fe2a11b29e0>) Those errors are only visible in Sublime Text console. While previously import errors where in the status bar.
Unable to open /opt/sublime_text/<string> This error did appear before the fix.
@ for a in range(10):
do_something()
@ print('Breakpoint here')
do_something_else() See custom interpreter data below for details. |
Python 3 [with custom virtualenv interpreter set via configuration file]
Traceback (most recent call last):
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/comm_utils.py", line 69, in __getitem__
ret = eval("self."+instruction)(*json.loads(parameters))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/backends/dbPython3.py", line 40, in E_get_cmd
def E_get_cmd (self, line,locals,globals,filename): return self.parent.get_cmd (line,locals,globals,filename)
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 69, in get_cmd
refresh_expressions()
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 297, in refresh_expressions
expressions = get_keys(get_view_content("Expression"))
File "/home/yaraslau/.config/sublime-text-3/Packages/Python Debugger/mydebugger.py", line 303, in get_keys
keys = [l.split(' ┃ ')[0].strip() for l in txt.split('\n')]
AttributeError: 'NoneType' object has no attribute 'split'
@ for a in range(10):
do_something()
@ print('Breakpoint here')
do_something_else() Most of the times it does manage to stop at them during first loop iteration. But then fails to do so during the following ones. |
Latest commit solves 3. Confirm |
Yes, number 3 seems to be gone. 2, 5 and 6 are still there though. |
And I also think it would be better to actually get interpreter command from currently active Sublime Build System as compared to using a config file. Otherwise people will have to edit the config every time they want to debug another project they are working on. Or do some more hacking to add each of their projects' interpreters to the And current Build System's interpreter (the one that is run by hitting |
Config editing is not available, the file "SublimeDebugger.sublime-settings" gots rewrited every time then choosing Python version from "Tools > Debugger > Set Language", rendering it as useless. |
I have an alternative build system set-up for my Python 3 project:
As you can see this one uses
python3.5
interpreter from a virtual environment with all specific dependencies installed.But Sublime Debugger plug-in seems to use the default
python3
interpreter.Is there a way to choose a specific "debugging" interpreter for each project?
Or add a functionality to utilize corresponding Build Systems' paths?
The text was updated successfully, but these errors were encountered: