Search code examples
pythonspyderpdb

Why is the python debugger throwing a ValueError before reaching my script?


When I try to debug a python script in the Spyder IDE using an exception is raised long before the debugger gets to my script. In spyderpdb.py near line 765 I get a ValueError reported. The full trace back is

debugfile('E:/anaylsis_scripts/measure_{0}_test_analysis/comparison_to_golden_measurement.py', wdir='E:/anaylsis_scripts/measure_{0}_test_analysis')
Traceback (most recent call last):

  File "C:\Users\****\AppData\Local\Temp/ipykernel_11140/1829221852.py", line 1, in <module>
    debugfile('E:/anaylsis_scripts/measure_{0}_test_analysis/comparison_to_golden_measurement.py', wdir='E:/anaylsis_scripts/measure_{0}_test_analysis')

  File "C:\Users\****\anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 607, in debugfile
    enter_debugger(

  File "C:\Users\****\anaconda3\lib\site-packages\spyder_kernels\customize\spyderpdb.py", line 765, in enter_debugger
    code = code_format.format(repr(filename))

ValueError: cannot switch from automatic field numbering to manual field specification

I am expect the debugger to run and throw exceptions in my script not from the inner workings of my IDE.

I am running:

  • Spyder version: 5.1.5 None
  • Python version: 3.8.12 64-bit
  • Qt version: 5.12.9
  • PyQt5 version: 5.12.3
  • Operating System: Windows 10

Solution

  • This is most likely happening because your path has {0} in it, which is a valid Python format specifier, and Spyder is mistakenly treating it as such. This looks like a bug in Spyder, you could consider reporting it.