Search code examples
pythonenthoughtcanopy

Different results in GUI vs terminal


I have one file that includes a class definition and another that imports that module. When I run the latter, it appears to not know that I edited the other file and continues to give me the same error. However, when I run it in a Canopy Terminal, it works as desired. Can anyone tell me why this is happening?

Thanks.


Solution

  • This is because IPython keeps your kernel process running, so the lower-level module remains imported (specifically it remains listed in sys.modules) so it is not re-imported when you re-run your main script. (Just as it would not be re-imported if you issued the import command twice in a row.) While perhaps counterintuitive at first, this is a deliberate feature. For detail, see https://support.enthought.com/hc/en-us/articles/204469240-IPython-After-editing-a-module-changes-are-not-effective-without-kernel-restart