Skip to content

Sometimes import numpy as np yields NameError: name 'testing' is not defined #9931

@standarddeviant

Description

@standarddeviant

I'm seeing a strange error about numpy 'testing' not being defined on an import of numpy.

Here's the traceback:

Exception in thread Thread-4: 
Traceback (most recent call last): 
  File "C:\Users\stddev\Documents\MATLAB\aplab_python\lib\threading.py", line 916, in _bootstrap_inner 
    self.run() 
  File "C:\Users\stddev\Documents\MATLAB\aplab_python\lib\threading.py", line 864, in run 
    self._target(*self._args, **self._kwargs) 
  File "C:\Users\stddev\src\aplab\ASR\AudioProcAsync.py", line 234, in AudioProcAsyncCreateReceiveJob_1 
    resp = AudioProcAsyncCreateJob_1(filePrefix, language, service) 
  File "C:\Users\stddev\src\aplab\ASR\AudioProcAsync.py", line 46, in AudioProcAsyncCreateJob_1 
    getAudioFile(filePrefix, fileTypes, maxChannels=2, format='linear16') 
  File "C:\Users\stddev\src\aplab\ASR\asrutils.py", line 615, in getAudioFile 
    data, rate = soundfile.read(tmpf, dtype='int16') 
  File "C:\Users\stddev\Documents\MATLAB\aplab_python\lib\site-packages\soundfile.py", line 375, in read 
    data = f.read(frames, dtype, always_2d, fill_value, out) 
  File "C:\Users\stddev\Documents\MATLAB\aplab_python\lib\site-packages\soundfile.py", line 961, in read 
    out = self._create_empty_array(frames, always_2d, dtype) 
  File "C:\Users\stddev\Documents\MATLAB\aplab_python\lib\site-packages\soundfile.py", line 1367, in _create_empty_array 
    import numpy as np 
  File "C:\Users\stddev\Documents\MATLAB\aplab_python\lib\site-packages\numpy\__init__.py", line 152, in <module> 
    test = testing.nosetester._numpy_tester().test 
NameError: name 'testing' is not defined 

I'm using a version of miniconda installed with numpy and other common packages.

The package doing this import is soundfile, but it looks like it's simply running import numpy as np. With the exact same code and input wave files, I see this error about 1% of the time.

By looking at numpy/__init__.py, I'm curious how testing is defined at all. It's not imported explicitly anywhere in the file. I noticed this is changed in master, but not yet in any release. Does anyone understand why this might work most of the time, but fail occasionally?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions