Search code examples
pythonpycharm

Debug a console_script with pycharm


I have a complex python program I'd like to debug where the setup.py has

 entry_points=dict(
      console_scripts=[
          'myprog = myprog.command:myprog_main',
      ]
  )

where the command.py has the logic to accept command so I can run something like

myprog process --config config.yaml 

Placing a breakingpoint in pycharm doesn't cause the program to stop, since doing python command.py process --config config.yaml doesn't do anything

I feel this something basic, but I couldn't find a way to debug this (using pycharm)


Solution

  • Let's take jupyter notebook as an example:

    In jupyter, it from jupyter_core.command import main, so what I need to do is placing a breakpoint in jupyter_core.command:main.

    And then, I need to add a configuration in Pycharm. Script path should be /path/to/jupyter, Parameters should be notebook.

    Next, I need to click Debug.

    I've done, I reach the breakpoint in jupyter_core.command:main.