I've installed Pyaudio by doing like described in this thread.

Even though I've set the LD_LIBRARY_PATH and ran the sudo ldconfig the Python script raises:

Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
  File "play1.py", line 1, in <module>
    import pyaudio
  File "/home/IoTree/.local/lib/python3.5/site-packages/pyaudio.py", line 116, in <module>
    import _portaudio as pa
ImportError: libportaudio.so.0: cannot open shared object file: No such file or directory

Here's my two last lines on ~/.bashrc:

alias python='/usr/bin/python3.5'
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib: /home/IoTree/.local/lib/python3.5/site-packages /

When I use the command to find the directory where libportaudio.so is located by doing like so: find -name "libportaudio.so" I got


Which means it exists but it is probably badly written in the ~/.bashrc.

Can someone help me on this? I've been struggling for 3 days now...


There shouldn't be spaces between /usr/local/lib: /home/IoTree/ and between site-packages / just a colon, I think. The spaces look wrong in the export LD_LIBRARY_PATH line

That is to say:

alias python='/usr/bin/python3.5'
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib: /home/IoTree/.local/lib/python3.5/site-packages /
                                                    ^^                    and                       ^^

So the lines should be:

alias python='/usr/bin/python3.5'
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib:/home/IoTree/.local/lib/python3.5/site-packages:/

Then again:

  • why is there a / at the end?
  • why is /usr/local/lib in the path twice?

The paths that you should use are


So try

alias python='/usr/bin/python3.5'
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/arm-linux-gnueabihf/:/home/IoTree/portaudio/lib/.libs:/home/IoTree/.local/lib/python3.5/site-packages

I'm not even sure if /home/IoTree/.local/lib/python3.5/site-packages is required, so this might suffice:

alias python='/usr/bin/python3.5'
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/arm-linux-gnueabihf/:/home/IoTree/portaudio/lib/.libs
  • You're welcome :-) Don't forget to upvote and accept (using the green tick) any answers that you found to be useful Aug 20 '18 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.