Python Forum
[split] Debugging scripts basics
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[split] Debugging scripts basics
#1
(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
Reply
#2
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.
Reply
#3
As a former PyCharm user. I's recomment VSCode.
Tutorial here: https://python-forum.io/Thread-VS-Code-f...ght=VSCode
Reply
#4
VS Code is pretty good. Especially if you are using kite.
Reply
#5
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.
Reply
#6
Off topic but kind of lean toward atom myself. Free, has lots of community support, and many plugins to help with coding.
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags


Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Learned Python Basics, what now? muzikman 20 5,986 Oct-11-2021, 01:34 AM
Last Post: Underscore
  PYserial basics? bako 10 5,100 Apr-26-2020, 09:15 PM
Last Post: bowlofred
  Debugging scripts basics bako 8 3,495 Apr-24-2020, 06:18 AM
Last Post: Larz60+
  Problem with basics Wraith2102 2 1,993 Jun-17-2019, 06:51 PM
Last Post: perfringo
  Dictionary Basics pythonjm 5 3,505 Nov-26-2018, 11:11 PM
Last Post: pythonjm
  What to do after learning python basics xyzabc12310000 1 2,851 May-20-2018, 11:43 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020