ipdb icon indicating copy to clipboard operation
ipdb copied to clipboard

Importing the module breaks the interpreter

Open wRAR opened this issue 9 years ago • 7 comments

When the module is imported in the python interpreter, which can be done not only explicitly, but also just by doing e.g. help(modules), some kind of ipython shell replaces the interpreter. If that can be avoided it is a good thing to do.

wRAR avatar Oct 30 '16 10:10 wRAR

Could you provide a simple test case?

gnebehay avatar Jan 20 '17 12:01 gnebehay

@gnebehay "import ipdb" in /usr/bin/python

wRAR avatar Jan 20 '17 12:01 wRAR

python
Python 3.5.3rc1 (default, Jan  3 2017, 04:40:57) 
[GCC 6.3.0 20161229] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipdb
Enabling autoreload.
Importing numpy, pyplot and pandas libraries
Using matplotlib backend: TkAgg
In :

Seems reproducable. Creating the IPython terminal should probably be deferred until debugging actually starts.

gnebehay avatar Jan 20 '17 13:01 gnebehay

@gnebehay , I noticed that when you executed import ipdb, it mentioned Enabling autoreload. How are you doing this?

I am trying to figure out how to autoload code while executing code through ipdb.

I have the following statement in my python code

import ipdb; ipdb.set_trace()

If I load the autoload extension using https://ipython.org/ipython-doc/3/config/extensions/autoreload.html

and then attempt to run my python function which contains the set_trace() statement from above, will ipdb automatically reload the code in the modules on each n, j while executing each line of code?

alphaCTzo7G avatar Mar 30 '18 17:03 alphaCTzo7G

This is actually due to my IPython profile, where I use the package to autoreload files while I am using the IPython shell. These are the relevant settings: https://github.com/gnebehay/common/blob/master/dotfiles/.ipython/profile_default/ipython_config.py I don't think that this package can swap code on-the-fly during debugging, but maybe there are other packages for this purpose.

gnebehay avatar Mar 30 '18 20:03 gnebehay

Thanks for the clarification. I will see if I can find any..

alphaCTzo7G avatar Apr 01 '18 23:04 alphaCTzo7G

I think this has been fixed, probably in 0.13.7?

wRAR avatar Dec 12 '21 10:12 wRAR