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

Time:07-16

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'

CodePudding user response:

"Runtimeerror" is complaining about the version of numpy.

Try the following:

pip install numpy --upgrade
  • Related