TL;DR: This issue appears to have been fixed in numpy 1.15 (at least, I didn't test 1.14) However, I also had some issues in my environment that I also fixed, so it may be that numpy's behavior hasn't changed -- I don't have the energy to test now. And it doesn't hurt to have this in the archives in case someone else runs into the problem. Read on if you care about weird behaviour with the testing package in numpy 1.13.... Numpy appears to be both running tests on import (or at lest the the runner), and finding local tests that are not numpy's I found this issue (closed without a resolution): https://github.com/numpy/numpy/issues/11457 which is related -- but it's about the import time of numpy.testing, and not about errors/issues from that import. But maybe the import process ahs been changed in newer numpys What I did, and what I got: I am trying t debug what looks like a numpy-related issue in a project. So one thing I did was try to import numpy and check __version__: python -c "import numpy; print(numpy.__version__)" very weird barf: <snip> File "/Users/chris.barker/miniconda2/envs/gridded/lib/python2.7/unittest/runner.py", line 4, in <module> import time File "time.py", line 7, in <module> import netCDF4 as nc4 File "/Users/chris.barker/miniconda2/envs/gridded/lib/python2.7/site-packages/netCDF4/__init__.py", line 3, in <module> from ._netCDF4 import * File "include/netCDF4.pxi", line 728, in init netCDF4._netCDF4 (netCDF4/_netCDF4.c:83784) AttributeError: 'module' object has no attribute 'ndarray I get the same thing if I fire up the interpreter and then import numpy as the error seemed to come from: unittest/runner.py I had a hunch. I was, in fact, running with my current working directory in the package dir of my project, and there is a test package in that dir I cd out of that, and presto! numy imports fine: $ python -c "import numpy; print(numpy.__version__)" 1.13.1 OK, that's a kinda old numpy -- but it's the minimum required by my project. (though I can probably update that -- I"ll do that soon) So it appears that the test runner is looking in the current working dir (or, I suppose sys.PATH) for packages called tests -- this seems like a broken system, unless you are runing the tests explicitly from teh command line, it shouldn't look in the cwd, and it probably shouldn't ever look in all of sys.path. BUt my bigger confusion here is -- why the heck is the test runner being run at ALL on a simple import ?!?!? If this has been fixed / changed in newer numpy's the OK -- I'll update my dependencies. -CHB - Christopher Barker, Ph.D. Oceanographer Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chris.Barker@noaa.gov
participants (1)
-
Chris Barker