0

I have installed multiple versions of python like 3.8.5 and 3.9.2 in my Linux Ubuntu system. I want to install pyaudio module in 3.9.2 version.
For this, I have used a command: pip3 install PyAudio and I am getting this error - error: Microsoft Visual C++ 14.0 is required.

I have also used python unofficial libraries and tried to install pyaudio but it shows this error -
ERROR: PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

Then I used these commands for the same -

  • sudo apt-get install libasound-dev portaudio19-dev libportaudio2 libportaudiocpp0
  • sudo apt-get install ffmpeg libav-tools
  • sudo pip install pyaudio

After this when I import pyaudio module, it shows module not found error. But when I tried to re-install the module, it shows requirement already satisfied.

Then I executed the command:

  • sudo -s
  • python3
  • import pyaudio

Now it shows no error. It seems that pyaudio module has been installed in python 3.8.5 version and not in python 3.9.2 version. However, I used virtual environment of older python version and installed speech recognition, pyaudio which worked well.

I want to use pyaudio module without using virtual environment without any errors. Please help.

Here is the screenshot of the issue
image_pyaudio_issue
Here is the code -
maaz@maaz-HP-Notebook:~$ python
Python 2.7.18 (default, Mar 8 2021, 13:02:45)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pyaudio
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named pyaudio
import PyAudio
Traceback (most recent call last):
File "", line 1, in
ImportError: No module named PyAudio
exit()
maaz@maaz-HP-Notebook:~$ sudo pip install pyaudio
[sudo] password for maaz:
Requirement already satisfied: pyaudio in /usr/lib/python3/dist-packages (0.2.11)

maaz@maaz-HP-Notebook:~$ sudo -s
[sudo] password for maaz:
root@maaz-HP-Notebook:/home/maaz# python3
Python 3.8.5 (default, May 27 2021, 13:30:53)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
import pyaudio

exit()
root@maaz-HP-Notebook:/home/maaz# exit
exit

  • The good practice is to create a virtual environnement for each of your Python project so that their dependencies dont get mixed up. You can also use conda an open source package management system and environment management system. – May.D Jun 28 '21 at 13:42
  • Does this answer your question? [Dealing with multiple Python versions and PIP?](https://stackoverflow.com/questions/2812520/dealing-with-multiple-python-versions-and-pip) – May.D Jun 28 '21 at 13:43
  • This message `PyAudio-0.2.11-cp39-cp39-win_amd64.whl is not a supported wheel on this platform` is because that is a Windows binary. And the message about `Microsoft Visual C++ 14.0 is required` is what you get from older versions of `pip` installs for Windows when `pip` tries to compile the extension from source and can't find an MSC compiler. That is an exclusively Windows message. – BoarGules Jun 28 '21 at 14:14

1 Answers1

0

Check in the usr/bin and usr/local/bin for all python instances.

The installation of python3 is probably linked to python 3.8.5. But there might be a python3.9.

You could check for other python instances in the above folders by running the below commands:

ls -ls /usr/bin/python*
ls -ls /usr/local/bin/python*

If so, you can run the commands with python3.9, but i would recommend cleaning up the unused installations.

RobinF
  • 349
  • 1
  • 2
  • 17
  • Thanks I have executed the command - which python3 output - /home/linuxbrew/.linuxbrew/bin/python3 . Please explain how to uninstall other versions of python. – Maaz Shaikh Jun 28 '21 at 17:27
  • You could use DPKG: https://unix.stackexchange.com/questions/195794/how-to-uninstall-a-deb-installed-with-dpkg . However I do not know if this also "renames" python3 to the correct installation. – RobinF Jun 29 '21 at 15:46