"Attribute error: pyo server not created"

I have been trying to run the following code on macOS Mojave version 10.14.3 using the latest Psychopy release (3.07)

from psychopy import microphone

microphone.switchOn()
mic = microphone.AudioCapture()
mic.record(5,filename = "test")

But I get the error message

 File "/Applications/PsychoPy3.app/Contents/Resources/lib/python3.6/psychopy/microphone.py", line 173, in __init__
    raise AttributeError('pyo server not created')
AttributeError: pyo server not created

I have seen on the forum that many people have met the same problem over the years but I have not been able to determine from that what was the source of the problem nor what solutions could be brought to it.

The code below seems to narrow down the problem a bit more:

import pyo
print(pyo.current_pyo)
print(pyo.current_pyo_path)

if pyo.serverCreated():
    print ("pyo running")
else:
    print ("No pyo server")

It returns “pyo not running”. It also indicates that the version of pyo is 0.8.8

Is there a way to manually start the pyo server? Why would it be not running in the first place? Do I need a more recent version of pyo than the one in the current distribution of psychopy? Is there another way to record audio in case this problem cannot be fixed?

Thanks a lot for any assistance!