Error when running python file on my Raspberry Pi 4b in Thonny

I am making a remote viewable camera with my Raspberry Pi 4b. I am following this tutorial: https://youtu.be/zfBHD4v8hD0?t=705

I am 11:45 into the tutorial, but when I click the run button, I get the following error:

RuntimeError: module compiled against API version 0xf but this version of numpy is 0xd
Traceback (most recent call last):
File "/home/pi/pi-camera-stream-flask/main.py", line 7, in <module>
from camera import VideoCamera
File "/home/pi/pi-camera-stream-flask/camera.py", line 5, in <module>
import cv2 as cv
File "/usr/local/lib/python3.9/dist-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/usr/local/lib/python3.9/dist-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: numpy.core.multiarray failed to import

I'm new to RPI, and I have no idea what this error means, or how to fix it.

I tried running

sudo apt-get install VideoCamera

and

sudo apt-get install camera

But it says that it cannot find the file.

EDIT: I ran pip install numpy --upgrade as suggested by userid42 And now I get the following error:

Traceback (most recent call last):
File "/home/pi/pi-camera-stream-flask/main.py", line 7, in <module>
from camera import VideoCamera
File "/home/pi/pi-camera-stream-flask/camera.py", line 6, in 
<module>
from imutils.video.pivideostream import PiVideoStream
ModuleNotFoundError: No module named 'imutils'

EDIT: Thanks to userid42 running the following fixed it:

pip install numpy --upgrade
pip install imutils

Now when I manually run the script in Thonny, it works, and I am able to view the camera live from any device that is connected to the same WIFI network.

Now I am trying to have the script run automatically when my RPI 4b is turned on.

I tried the method shown in the video, and also the first two methods here: https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/

All three of these methods return the same error I was having to begin with. This is weird because it works fine when I run it manually, but it gives the error when it runs automatically (on startup).



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations