Python Forum
[split] Debugging scripts basics - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: [split] Debugging scripts basics (/thread-26234.html)



[split] Debugging scripts basics - tultalk - Apr-24-2020

(Apr-24-2020, 02:58 AM)buran Wrote: Why not use an IDE with debugging?
What is a good IDE w/debugging to use in 2.7?
I am using the pdb and can't get breakoiint to work:

python -m pdb /usr/local/lib/python2.7/dist-packages/examples/simpletest.py

(Pdb) b Adafruit_ADS1x15/ADS1x15.py:134

Response:
Breakpoint 1 at /usr/local/lib/python2.7/dist-packages/Adafruit_ADS1x15/ADS1x15.py:134

(Pdb) run
Restarting /usr/local/lib/python2.7/dist-packages/examples/simpletest.py with arguments:

(Pdb) commands 1
(com) print result[1]
(com) end
(Pdb) r
Does not stop at breakpoint

postmortom:

(Pdb) c
Reading ADS1x15 values, press Ctrl-C to quit...
| 0 | 1 | 2 | 3 |
-------------------------------------
Error:
Traceback (most recent call last): File "/usr/lib/python2.7/pdb.py", line 1314, in main pdb._runscript(mainpyfile) File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript self.run(statement) File "/usr/lib/python2.7/bdb.py", line 400, in run exec cmd in globals, locals File "<string>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/examples/simpletest.py", line 42, in <module> values[i] = adc.read_adc(i, gain=GAIN) File "/usr/local/lib/python2.7/dist-packages/Adafruit_ADS1x15/ADS1x15.py", line 192, in read_adc return self._read(channel + 0x04, gain, data_rate, ADS1x15_CONFIG_MODE_SINGLE) File "/usr/local/lib/python2.7/dist-packages/Adafruit_ADS1x15/ADS1x15.py", line 133, in _read result = self._device.readList(ADS1x15_POINTER_CONVERSION, 2) File "/usr/local/lib/python2.7/dist-packages/Adafruit_GPIO/I2C.py", line 134, in readList results = self._bus.read_i2c_block_data(self._address, register, length) File "/usr/local/lib/python2.7/dist-packages/Adafruit_PureIO/smbus.py", line 216, in read_i2c_block_data cmdstring[i] = val TypeError: one character string expected Uncaught exception. Entering post mortem debugging
Why not stopping on breakpoint and showing value?

Thanks


RE: [split] Debugging scripts basics - deanhystad - Apr-24-2020

I've used PyCharm Community and Visual Studio Code on Windows. Both are free and I think they work pretty well. I think you can tell either which python or virtual environment they are supposed to use.


RE: [split] Debugging scripts basics - Larz60+ - Apr-24-2020

As a former PyCharm user. I's recomment VSCode.
Tutorial here: https://python-forum.io/Thread-VS-Code-from-start?highlight=VSCode


RE: [split] Debugging scripts basics - deanhystad - Apr-24-2020

VS Code is pretty good. Especially if you are using kite.


RE: [split] Debugging scripts basics - bowlofred - Apr-24-2020

It looks to me like you set a breakpoint for line 134 in ADS1x15.py. But your traceback shows an error was thrown from line 133 of that file. So I suspect that line 134 was never reached.

Try setting a breakpoint before line 133.


RE: [split] Debugging scripts basics - menator01 - Apr-25-2020

Off topic but kind of lean toward atom myself. Free, has lots of community support, and many plugins to help with coding.