簡體   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