Lots of missing libraries

Hi guys! It’s me again :sweat_smile:

I recently did a bad thing and messed up a crontab call, so had to erase all my work from my Raspberry Pi’s SD card (booo). Luckily I had it all backed up on a repository (yaaay).

However, when I’ve come to reinstall Edge Impulse on my device, I can’t remember whatever wizardry and magic I did to make it work last time. It wasn’t anywhere as difficult as it is now, so I must be missing a step. I went over my previous thread and tried everything in there in different ways to no avail.

I keep getting messages such as:
Could not import the PyAudio C module ‘_portaudio’.
Traceback (most recent call last):
File “classifier.py”, line 10, in
from edge_impulse_linux.image import ImageImpulseRunner
File “/usr/local/lib/python3.7/dist-packages/edge_impulse_linux/init.py”, line 2, in
from edge_impulse_linux import audio
File “/usr/local/lib/python3.7/dist-packages/edge_impulse_linux/audio.py”, line 3, in
import pyaudio
File “/usr/local/lib/python3.7/dist-packages/pyaudio.py”, line 116, in
import _portaudio as pa
ImportError: libportaudio.so.2: cannot open shared object file: No such file or directory

I’ve had this with OpenCV too, and have to install all the libraries manually, which I certainly didn’t have to do last time. I installed edge impulse using the command “sudo python3 -m pip install edge_impulse_linux” and when I try to reinstall it to make sure I have the necessary libraries it tells me:

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: edge_impulse_linux in /usr/local/lib/python3.7/dist-packages (1.0.4)
Requirement already satisfied: opencv-python==4.5.1.48 in /usr/local/lib/python3.7/dist-packages (from edge_impulse_linux) (4.5.1.48)
Requirement already satisfied: PyAudio==0.2.11 in /usr/local/lib/python3.7/dist-packages (from edge_impulse_linux) (0.2.11)
Requirement already satisfied: numpy>=1.19 in /usr/local/lib/python3.7/dist-packages (from edge_impulse_linux) (1.21.0)
Requirement already satisfied: psutil==5.8.0 in /usr/local/lib/python3.7/dist-packages (from edge_impulse_linux) (5.8.0)

I’m baffled, can anyone offer me any assistance please? This time around when things are working I’ll be making a clone of my SD card so I can redistribute in the future a lot easier! Thanks in advance.

Hello @TechDevTom,

Can you make sure you have installed these dependencies like in our Python SDK documentation:

$ sudo apt-get install libatlas-base-dev libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
$ pip3 install edge_impulse_linux -i https://pypi.python.org/simple

Regards,

Louis

Hey @louis, I completely missed this, as I was following the Raspberry Pi 4 guide rather than the Linux one. Is it possible to include as part of the linked Raspberry Pi 4 guide a link to the Linux requirements as part of the installation steps for the Raspberry Pi 4 setup please? Unless there’s one already and I missed it?

This would have solved a lot of issues for me and saved me some time :sweat_smile: I’ll give the commands on that page a go and see how I get on, cheers!

Hi @louis, I’ve followed the instructions given on the page you linked, do I also need to follow the instructions on the Raspberry Pi guide? I have done both, doing the Linux instructions first, then doing step 2 of the Raspberry Pi guide to install other dependencies, and I’m getting the following issue:

Traceback (most recent call last):
  File "classifier.py", line 3, in <module>
    import cv2
ModuleNotFoundError: No module named 'cv2'

I’ve put an instructions list of exactly what I’ve done in a Google Docs document and have sent you a PM with the link to it there. Could you please take a look and see if I’m doing anything wrong. I’m at my wits end, as I need the cv2 module since it’s part of the demo code Jan gave to me. I’ve got info previously in my other posts on how to install things properly, but I’m not sure which is the proper way of doing things, as it conflicts at times with the Raspberry Pi 4 guide.

Sorry for the bother, and thanks in advance!

Hello,

You need to install openCV too in your case,
It is not part of our documentation because you are using a custom piece of code (I guess you are refering to this: Raspberry Pi 4 Object Detection - A Camera Question).

To install openCV, you can do something like this on your raspberry:

pip3 install opencv-python

Regards,

Louis

Hello again, so that worked, and then it told me numpy wasn’t the right version:
“RuntimeError: module compiled against API version 0xe but this version of numpy is 0xd” so I fixed that with the command “pip3 install --upgrade numpy”.

And now? I’m getting:

Traceback (most recent call last):
  File "classifier.py", line 10, in <module>
    from edge_impulse_linux.image import ImageImpulseRunner
ModuleNotFoundError: No module named 'edge_impulse_linux'

Even though I’ve followed what I believe are to be all of the correct instructions. Sorry @louis, going to have to ask for your help again here.

I remember from that post Raspberry Pi 4 Object Detection - A Camera Question you had both Python2 and Python3 installed, if you backed up your RPi4 maybe it is still the case.

Can you make sure you are using Python3 to execute your script please?

And if so but you still have issues, instead of installing the packages using

pip3 install your-package

can you do that:

python3 -m pip install your-package

I hope this will help,

Regards,

Louis

Cheers @louis, I have already changed my Raspberry Pi to use Python 3 rather than 2, and when checking the version using the below it states that it’s Python 3.7.3.
python --version

I’ll go and reformat my SD card again, and walk through everything step by step using
python3 -m pip install your-package

If I have no luck still, I’ll get back to you. I have a feeling I’m doing something wrong or missing a step, but if what I sent you in that PM makes sense and seem logical, then maybe I’m just going insane.

Best,
Tom

Thank goodness, that worked @louis, I used

python3 -m pip install edge_impulse_linux -i https://pypi.python.org/simple

rather than

pip3 install edge_impulse_linux -i https://pypi.python.org/simple

from the link you sent https://docs.edgeimpulse.com/docs/linux-python-sdk and it worked.

I’ve updated my installation guide now so that I know what to do next time. I’m afraid my Linux installation knowledge regarding Python/apt-get/npm/pip etc. is very basic, hence why I got lost here.

Thank you again Louis, and to the Edge Impulse team for your patience. I’m going to go clone this SD card image to save some time for the next round :sweat:

1 Like