Cant install pyaudio in pycharm

Successfully built PyAudio
Installing collected packages: PyAudio
Successfully installed PyAudio-0.2.12

I got this message on the terminal but this error was from pycharm terminal

31 | #include "portaudio.h"
| ^~~~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-unknown-linux-gnu-gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for PyAudio
Failed to build PyAudio
ERROR: Could not build wheels for PyAudio, which is required to install pyproject.toml-based projects

Do you have the dev packages installed?

sudo apt install python3-dev libffi-dev

libffi-dev is already the newest version (3.3-4).
python3-dev is already the newest version (3.8.2-0ubuntu2).
python3-dev set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Do you have build-essential installed (You should...)

What version(s) of Python do you have installed?
If I recall correctly, you had recently installed Python10, too...right?

when I check "python3 -V" it shows Python 3.8.10 and when "python -V" it shows
Python 3.10.7 in the terminal. so, which is the default? I mean pycharm detects python 3.10 and qt creator does not detect python 3.10. I can't understand.

This is the problem with having more than One Python version installed.
I believe it is auto-aiming toward the latest python 10 and... looking for gcc version higher than 9.4.0.

now what should i do?

What version of Pyaudio are you installing?

PyAudio-0.2.12

Maybe try version 0.2.9...
And do you have libasound-dev installed?

Note, selecting 'libasound2-dev' instead of 'libasound-dev'
libasound2-dev is already the newest version (1.2.2-2.1ubuntu2.5).
libasound2-dev set to manually installed.

I am honestly not sure...
I ensure that I avoid changing Python out. I have seen doing so create such chaos...

system python version is 3.8 so how to upgrade to latest?

Zorin only supports Python till 3.8 as it is ubuntu 20.04. If you upgrade further the system will break and you need to reinstall it.

if so, should detect automatically in pycharm and qt creator, but no. so how to uninstall 3.10 and detect default?

So, you installed itπŸ˜’
Try,

sudo update-alternatives  --set python3 /usr/bin/python3.8
sudo update-alternatives  --set python /usr/bin/python3.8
sudo apt install ppa-purge
sudo ppa-purge ppa:deadsnakes/ppa

Removing ppa should solve some issues.

is it safe? i am afraid about purge command. I broke the system for purge python3.8.

We are not purging yet, Just trying to remove the repsitory of 3.10 and trying to get back 3.8. Btw are you not using idle or something like that for python? Why did you update the OS python rather than updating the interpreter.

Why did you update the OS python rather than updating the interpreter.

how to update interpreter?

Update alternatives essentially creates an alias that non-system processes use to execute commands. (It does much more than this, but goes beyond the scope of your issue ). That is why aliasing python3 didn't work for me (i had tried to alias python3 to python, but you can't alias an alias).

At the time of my install, Python 2 was still installed and being used by the system, so I couldn't use python in the update alternatives cause it would break python 2.

If you remove the update alternatives entries, then redo them using python3, in terminal it will utilize 3.10 libraries. The way it was installed on your system, PyAudio was placed under 3.8 because there was only one version on python3 (python 3.8).

When you installed python 3.10, you should have also installed python3-venv and pip3. The virtual environment library would allow you to set up a development virtual environment to install the libraries to that project and sandbox them from the system, forcing them to use the development version of python instead of the system's version (as long as update alternatives was setup correctly). Adding libraries to the system version can cause conflicts.

If you used the apt install command to install python 3.10, use the apt remove python3. It should only remove 3.10. Remove PyAudio prior to Uninstalling python 3.10.

Is 3.10 necessary? Without adding any repositories you can get the latest of python 3.9 by apt install python3 python3-venv pip3 (after removing the deadnake ppa). Unless your project requires the features of python 3.10 (switch functionality and a few other things), you can use 3.9.

After the install, set update alternatives (using python3 to set it up and change between) to the newly installed version (which changes it to manual). If you leave it on default (automatic) it will never utilize python 3.10.

Here is a pretty good tutorial on setting it up, explains virtual environments and their setup as well; Installing multiple alternative versions of Python on Ubuntu 20.04 | by Mathanraj Sharma | Towards Data Science.

1 Like