简体   繁体   English

在 Thonny IDE 的 CLI bot 中导入 picamera2 工作

[英]Importing picamera2 works in CLI bot in Thonny IDE

I have successfully installed picamera2 using this tutorial and I am able to run a script just fine from CLI.我已经使用本教程成功安装了 picamera2,并且可以从 CLI 运行脚本。 The script:剧本:

from picamera2.picamera2 import *
from time import sleep

picam2 = Picamera2()

picam2.start_preview(Preview.QTGL)

config = picam2.preview_configuration()
picam2.configure(config)

picam2.start()
sleep(5)

And I run it in terminal python script_name.py and it works as it should.我在终端python script_name.py中运行它,它可以正常工作。 But when I run it in Thonny IDE the script returns:但是当我在 Thonny IDE 中运行它时,脚本返回:

ModuleNotFoundError: No module named 'picamera2' ModuleNotFoundError:没有名为“picamera2”的模块

To my knowledge I have set the default interpreter in Thonny \usr\bin\python3 and tried also with \usr\bin\python3.9 and \usr\bin\python - they all seem to point to python version 3.9.2 - which is also the version displayed in terminal when running python -V or python3 -V .据我所知,我已经在 Thonny \usr\bin\python3中设置了默认解释器,并尝试了\usr\bin\python3.9\usr\bin\python - 它们似乎都指向 python 版本 3.9.2 - 其中也是运行python -Vpython3 -V时终端中显示的版本。 What am I missing or doing incorrectly?我错过了什么或做错了什么?

sudo apt install python3-picamera2

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

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