From 791c09db3b187257e53f79725c13c1efdb4ff458 Mon Sep 17 00:00:00 2001 From: Matthias Geier Date: Sat, 2 Sep 2023 10:17:56 +0200 Subject: Import NumPy in _StreamBase.__init__ --- sounddevice.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sounddevice.py b/sounddevice.py index fe8ca12..7fc7c10 100644 --- a/sounddevice.py +++ b/sounddevice.py @@ -769,6 +769,12 @@ class _StreamBase: """ assert kind in ('input', 'output', 'duplex') assert wrap_callback in ('array', 'buffer', None) + if wrap_callback == 'array': + # Import NumPy as early as possible, see: + # https://github.com/spatialaudio/python-sounddevice/issues/487 + import numpy + assert numpy # avoid "imported but unused" message (W0611) + if blocksize is None: blocksize = default.blocksize if clip_off is None: -- cgit v1.2.3