How to debug "python -m module_name" using pudb
Question:
I have the following python call:
python -m module_name
The file structure is as below:
module_name
__init__.py
__main__.py
Previously, I debug using pudb for signle python program without -m
in the following way:
python -m pudb.run file_name.py
Considering this, I tried the following command but got error:
python -m pudb.run -m module_name
Error messages:
Usage: run.py [options] SCRIPT-TO-RUN [SCRIPT-ARGUMENTS]
run.py: error: no such option: -m
Is there any solution for debug ‘python -m module_name’ using pudb?
Answers:
Not an exact solution to your problem, but if you cannot find a way to do it like that, you can instead import and start pudb in your module, for example in the __main__.py file:
import pudb
pu.db
# Rest of your module code
And then run it with
python -m module_name
It will automatically start in pudb that way.
This is supported now. see this merged PR
pudb3 -m some_module
It also works if you use pudb
itself as an executable module:
python -m pudb -m some_module
I have the following python call:
python -m module_name
The file structure is as below:
module_name
__init__.py
__main__.py
Previously, I debug using pudb for signle python program without -m
in the following way:
python -m pudb.run file_name.py
Considering this, I tried the following command but got error:
python -m pudb.run -m module_name
Error messages:
Usage: run.py [options] SCRIPT-TO-RUN [SCRIPT-ARGUMENTS]
run.py: error: no such option: -m
Is there any solution for debug ‘python -m module_name’ using pudb?
Not an exact solution to your problem, but if you cannot find a way to do it like that, you can instead import and start pudb in your module, for example in the __main__.py file:
import pudb
pu.db
# Rest of your module code
And then run it with
python -m module_name
It will automatically start in pudb that way.
This is supported now. see this merged PR
pudb3 -m some_module
It also works if you use pudb
itself as an executable module:
python -m pudb -m some_module