[IPython-user] dreload numpy - source dir error

Robin robince@gmail....
Fri Dec 5 12:12:27 CST 2008


I thought I had seen this come up but I can't find it - so sorry if it has...

I have an error using dreload with numpy... I get the error about
importing numpy in the source directory whenever I try to dreload
something that uses numpy. For the most part it does seem to work (I'm
not changing numpy - its my own code I'm trying to dreload) but the
long trace back is a bit annoying because it breaks the list of
results when scrolling through the history...

Anyway here is an example:

robin-mbp:amaripool robince$ ipython
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
Type "copyright", "credits" or "license" for more information.

IPython 0.9.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.
In [1]: import numpy
In [2]: reload numpy
------> reload(numpy)
Out[2]: <module 'numpy' from
In [3]: dreload numpy
------> dreload(numpy)
Reloading numpy
Reloading numpy.numpy
Reloading numpy.show
ImportError                               Traceback (most recent call last)

/Users/robince/phd/amaripool/<ipython console> in <module>()

in reload(module, exclude)
    179     __builtin__.__import__ = deep_import_hook
    180     try:
--> 181         ret = deep_reload_hook(module)
    182     finally:
    183         __builtin__.__import__ = original_import

in deep_reload_hook(module)
    157     name = module.__name__
    158     if '.' not in name:
--> 159         return import_module(name, name, None)
    160     i = name.rfind('.')
    161     pname = name[:i]

in import_module(partname, fqname, parent)
    146     try:
--> 147         m = imp.load_module(fqname, fp, pathname, stuff)
    148     finally:
    149         if fp: fp.close()

in <module>()
    119         its source directory; please exit the numpy source
tree, and relaunch
    120         your python intepreter from there."""
--> 121         raise ImportError(msg)
    122     from version import version as __version__

ImportError: Error importing numpy: you should not try to import numpy from
        its source directory; please exit the numpy source tree, and relaunch
        your python intepreter from there.



More information about the IPython-user mailing list