Python import sounddevice as sd (ImportError: No module name sounddevice)

Viewed 15879

I have python code that is running on raspberry pi B++ that uses the sounddevice library that lets you play and record sounds with python. I have successfully installed the modules. I can confirm through the python command line and enter import sounddevice as sd is works without errors. I have also confirmed by typing help ('modules') in python command line and sounddevice module appears. Only when I am running this code in an independent python program does the ImportError: No module name sounddevice appear.

Hope some one can help.

Here is the included code:

import sounddevice as sd

The error:

ImportError: No module name sounddevice

4 Answers

Install sounddevice using pip from anaconda prompt:

open anaconda prompt and type in :

pip install sounddevice --user

it worked for me

I had this same problem on Windows 10 even after eliminating the --user part of the pip install command. For some reason, installing pyaudio first resolved the problem with sounddevice. Sounddevice continues to work even after uninstalling pyaudio. They're both based on Portaudio so perhaps there's something shared in there, but I am not sure.

You have not installed sounddevice module. It was giving me errors constantly while installing it using pip. So, I had to install it using conda in the desired environment separately. You can follow the given procedure.

Step 1: Open Anaconda Prompt. (Install Anaconda in case you don't have it)

Step 2: Type the following to get all the environments

conda env list

Step 3: Move into the environment you want to install sounddevice

conda activate name_of_any_desired_env

For Example:

conda activate mytestenv

Step 4: Install sounddevice using one of the following commands. You have to try all the commands in case the first one does not work for you.

conda install -c conda-forge python-sounddevice

OR

conda install -c conda-forge/label/gcc7 python-sounddevice

OR

 conda install -c conda-forge/label/cf201901 python-sounddevice

OR

 conda install -c conda-forge/label/cf202003 python-sounddevice

The very first worked for me, and I am using it on Python 3.7.

enter image description here

You can check this official page for installing the latest version

Related