From 0f9502e78773f1a6fa57a52a6a33b9e64d1b3e78 2013-07-13 00:41:18 From: MinRK Date: 2013-07-13 00:41:18 Subject: [PATCH] warn about names clobbered by `%pylab` --- diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index db88ce5..60f731f 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -2865,9 +2865,17 @@ class InteractiveShell(SingletonConfigurable): % (gui, " ".join(sorted(backends.keys())))) return except ImportError: - error("pylab mode doesn't work as matplotlib could not be found." + \ + error("pylab mode doesn't work as matplotlib or its backend could not be imported." + \ "\nIs it installed on the system?") return + # warn about clobbered names + ignored = set(["__builtins__"]) + both = set(ns).intersection(self.user_ns).difference(ignored) + clobbered = [ name for name in both if self.user_ns[name] is not ns[name] ] + if clobbered: + warn("pylab import has clobbered these variables: %s" + "\n`%%pylab --no-import` prevents imports from pylab, numpy, etc." % clobbered + ) self.user_ns.update(ns) self.user_ns_hidden.update(ns) # Now we must activate the gui pylab wants to use, and fix %run to take