[英]Error when running python file on my Raspberry Pi 4b in Thonny
I am making a remote viewable camera with my Raspberry Pi 4b.我正在用我的 Raspberry Pi 4b 制作远程可视相机。 I am following this tutorial: https://youtu.be/zfBHD4v8hD0?t=705
我正在关注本教程: 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:我在 11:45 进入教程,但是当我单击运行按钮时,出现以下错误:
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.我是 RPI 的新手,我不知道这个错误是什么意思,或者如何解决它。
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:编辑:我按照 userid42 的建议运行
pip install numpy --upgrade
userid42
现在我收到以下错误:
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:编辑:感谢
userid42
运行以下修复它:
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.现在,当我在 Thonny 中手动运行脚本时,它可以工作,并且我可以从连接到同一 WIFI 网络的任何设备实时查看摄像机。
Now I am trying to have the script run automatically when my RPI 4b is turned on .现在我试图让脚本在我的 RPI 4b 打开时自动运行。
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/我尝试了视频中显示的方法,以及这里的前两种方法: 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).
这很奇怪,因为当我手动运行它时它工作正常,但是当它自动运行时(在启动时)它会给出错误。
"Runtimeerror" is complaining about the version of numpy. “Runtimeerror”是在抱怨 numpy 的版本。
Try the following:尝试以下操作:
pip install numpy --upgrade
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.