[Numpy-discussion] A question about import in numpy and in place build

Robert Kern robert.kern@gmail....
Fri Mar 13 01:38:12 CDT 2009

On Fri, Mar 13, 2009 at 01:13, David Cournapeau
<david@ar.media.kyoto-u.ac.jp> wrote:
> Robert Kern wrote:
>>> Is adding additional imports fine too ? Or should we fix those in the
>>> unittest instead to avoid more namespace pollution ?
>> What do you mean?
> For example, we have:
> ======================================================================
> ERROR: Failure: ImportError (cannot import name format)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/var/lib/python-support/python2.5/nose/loader.py", line 364, in
> loadTestsFromName
>    addr.filename, addr.module)
>  File "/var/lib/python-support/python2.5/nose/importer.py", line 39, in
> importFromPath
>    return self.importFromDir(dir_path, fqname)
>  File "/var/lib/python-support/python2.5/nose/importer.py", line 84, in
> importFromDir
>    mod = load_module(part_fqname, fh, filename, desc)
>  File "/usr/media/src/dsp/numpy/git/numpy/lib/tests/test_format.py",
> line 286, in <module>
>    from numpy.lib import format
> ImportError: cannot import name format
> But there is no numpy.lib.format.py-related import at all in
> numpy.lib.__init__.py.

There shouldn't need to be (and also, there shouldn't be, in this
case). That's an odd bug in nose, then. It should be able to import a
module from a package. Nothing needs to be in __init__.py for that to

FWIW, I just change to a different directory, and the in-place build tests fine.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the Numpy-discussion mailing list