繁体   English   中英

没有名为“picamera”的模块

[英]No module named ‘picamera'

我跟着这个网站( https://www.pyimagesearch.com/2015/03/30/accessing-the-raspberry-pi-camera-with-opencv-and-python/ )来设置我的picamera,但我有一个问题使用 picamera 模块。 我确实安装了 picamera 模块,这张图片来自 pip freeze。

https://imgur.com/a/3y5b2rO

你可以看到我已经有 picamera 1.13,但是当我尝试 test_image.py 时,它说“没有名为‘picamera’的模块”。

https://imgur.com/a/XMEXwXJ

我已经卸载并安装了很多次,但错误仍然存​​在。 我该如何解决?

test_image.py

# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2

# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
rawCapture = PiRGBArray(camera)

# allow the camera to warmup
time.sleep(0.1)

# grab an image from the camera
camera.capture(rawCapture, format="bgr")
image = rawCapture.array

# display the image on screen and wait for a keypress
cv2.imshow("Image", image)
cv2.waitKey(0)

对于python3,您必须在下面的命令中尝试此操作。请记住,您需要在主目录中打开终端。

sudo -H apt install python3-picamera
sudo -H pip3 install --upgrade picamera[array]

让我知道它是否有效!

当您运行命令pip3 install picamera 时,它会显示要求已经满足,后跟路径,如果您已经安装了 picamera。 现在复制该路径并将其包含在您的程序中,如下所示:

    import sys
    sys.path.append('paste the copied path here')
    from picamera.array import PiRGBArray
    from picamera import PiCamera

我遇到了同样的问题,直到我注意到我没有在 PiCamera 中大写 c

尝试以下命令: https : //www.raspberrypi.org/documentation/linux/software/python.md

我假设 picamera 模块的路径由于某种原因搞砸了,所以尝试清除它并重新安装它。

清除使用:

sudo apt purge python3-picamera

首先确保一切都是最新的:

sudo apt update

然后:

sudo apt install python3-picamera

使用以下步骤安装 picamera 模块

1.On Windows, execute: set READTHEDOCS=True

1'.On Unix based systems, execute: export READTHEDOCS=True

2.Now execute: pip install picamera

Pi 相机可能无法在 Windows 上运行尝试以下命令,它将解决问题

执行:

set READTHEDOCS=True

现在执行:

pip install picamera

当我有一个名为 picamera.py 的文件时,我遇到了同样的问题,所以我重命名了它,因为更多的问题。 我希望它对你来说也是一样,否则它超出了我的技能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM