You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RuntimeWarning: 'ipdb.__main__' found in sys.modules after import of package 'ipdb', but prior to execution of 'ipdb.__main__'; this may result in unpredictable behaviour warn(RuntimeWarning(msg))
#221
Open
alayamanas opened this issue
Mar 6, 2021
· 4 comments
/root/.miniconda3/lib/python3.6/runpy.py:125: RuntimeWarning: 'ipdb.__main__' found in sys.modules after import of package 'ipdb', but prior to execution of 'ipdb.__main__'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
What does this mean and how do I fix it? Thank you!
ps: ipdb version 0.13.5
The text was updated successfully, but these errors were encountered:
@alayamanas If this is possible on your system, try running ipdb directly:
ipdb3 test.py
Since several others (over 1000 reported views) have run into this as well, it might be worth fixing.
Some background
In Python 3, when you run python -m it first imports the module (runs __init__.py) and then__main__.py directly.
There is no easy way to tell in __init__.py whether ipdb was run with the -m flag.
Two possible solutions
Do as many other libraries: move most of the main logic into a new file, e.g. ipdb.py and import from there, both in __init__.py and also in __main__.py.
Move most of the logic and main() function into __init__.py and import main from __main__.py.
@gotcha The most important thing to understand is what python -m does in Python3 (see my above post). After that, it boils down to moving most lines from __main__.py to another file. Either to a new file (e.g. ipdb.py) or to __init__.py.
Hope that helps. For the solution (1) you can see most CLIs out there, for example flask or pip. The solution (2) I haven't seen in the wild I think, but it should work just as well. The important thing here is to understand what python -m does.
My command is :
python -m ipdb test.py
and I got:
What does this mean and how do I fix it? Thank you!
ps: ipdb version 0.13.5
The text was updated successfully, but these errors were encountered: