I've been trying to test out manipulating my Raspberry Pi Camera Module 3 through Thonny but I've been getting the "ModuleNotFoundError: No module named 'picamera' " and I'm not quite sure why. It's my first time using this so bare with me, this is what I've done:
I used these commands to install OpenCV:
sudo apt-get install python3-pip python3-virtualenv
mkdir project
cd project
python3 -m pip install virtualenv
python3 -m virtualenv env
source env/bin/activate
sudo apt install -y build-essential cmake pkg-config libjpeg-dev libtiff5-dev libpng-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libfontconfig1-dev libcairo2-dev libgdk-pixbuf2.0-dev libpango1.0-dev libgtk2.0-dev libgtk-3-dev libatlas-base-dev gfortran libhdf5-dev libhdf5-serial-dev libhdf5-103 libqt5gui5 libqt5webkit5 libqt5test5 python3-pyqt5 python3-dev
pip install "picamera[array]"
pip install opencv-contrib-python
Then I went to sudo nano boot/firmware/config.txt > camera_auto_detect=0 >then added dtoverlay=imx708 under [all]
So that allowed me to use the camera without python.
I went to Thonny, I changed (maybe I didn't do it right) the interpreter to the virtual enviornment that I have OpenCV, the picamera[array]
I tried to import Opencv and tell me the version of it and it worked.
so I copy-pasted this code:
from picamera2 import Picamera2, Preview
import time
picam2 = Picamera2()
camera_config = picam2.create_preview_configuration()
picam2.configure(camera_config)
picam2.start_preview(Preview.QTGL)
picam2.start()
time.sleep(2)
picam2.capture_file("test.jpg")
and it gives me the module error in the first line for 'picamera2'
I opened a new terminal in the raspberry and tried to install the PiCamera without the virtual environment. I used sudo apt install -y python3-picamera2 and it gave me "python3-picamera2 is already the newest version (0.3.17-1) and 0 upgraded, newly installed, to remove and not upgraded. So it's definitely installed somewhere, but how could I use it in Thonny or how can I reinstall it in the virtual environment I created?
Btw I'm using a Raspberry Pi 4 B
I used these commands to install OpenCV:
sudo apt-get install python3-pip python3-virtualenv
mkdir project
cd project
python3 -m pip install virtualenv
python3 -m virtualenv env
source env/bin/activate
sudo apt install -y build-essential cmake pkg-config libjpeg-dev libtiff5-dev libpng-dev libavcodec-dev libavformat-dev libswscale-dev libv4l-dev libxvidcore-dev libx264-dev libfontconfig1-dev libcairo2-dev libgdk-pixbuf2.0-dev libpango1.0-dev libgtk2.0-dev libgtk-3-dev libatlas-base-dev gfortran libhdf5-dev libhdf5-serial-dev libhdf5-103 libqt5gui5 libqt5webkit5 libqt5test5 python3-pyqt5 python3-dev
pip install "picamera[array]"
pip install opencv-contrib-python
Then I went to sudo nano boot/firmware/config.txt > camera_auto_detect=0 >then added dtoverlay=imx708 under [all]
So that allowed me to use the camera without python.
I went to Thonny, I changed (maybe I didn't do it right) the interpreter to the virtual enviornment that I have OpenCV, the picamera[array]
I tried to import Opencv and tell me the version of it and it worked.
so I copy-pasted this code:
from picamera2 import Picamera2, Preview
import time
picam2 = Picamera2()
camera_config = picam2.create_preview_configuration()
picam2.configure(camera_config)
picam2.start_preview(Preview.QTGL)
picam2.start()
time.sleep(2)
picam2.capture_file("test.jpg")
and it gives me the module error in the first line for 'picamera2'
I opened a new terminal in the raspberry and tried to install the PiCamera without the virtual environment. I used sudo apt install -y python3-picamera2 and it gave me "python3-picamera2 is already the newest version (0.3.17-1) and 0 upgraded, newly installed, to remove and not upgraded. So it's definitely installed somewhere, but how could I use it in Thonny or how can I reinstall it in the virtual environment I created?
Btw I'm using a Raspberry Pi 4 B
Statistics: Posted by cbarreto — Sat Apr 20, 2024 12:57 am