Reputation: 126
I'm trying to run a python script in my Rasbperry pi that imports the package picamera2. Specifically using from picamera2 import Picamera2,Preview
However, I'm getting this error:
ImportError: No module named 'picamera2'
Struggling to get it installed. Why can't this package be found?
I've tried to install the package by doing an update and installing the package (as indicated in https://github.com/raspberrypi/picamera2)
sudo apt update
sudo apt full-upgrade
sudo apt install -y python3-picamera2
But running the last line returns the error: Unable to locate package python3-picamera2
I've also tried pip install picamera2
but that returns No matching distribution found for picamera2
Info:
Upvotes: 0
Views: 7585
Reputation: 1782
Citing documentation:
Picamera2 is only supported on Raspberry Pi OS Bullseye (or later) images
You are on Stretch (2 versions older than Bullseye). That's probably why you cant install it with apt.
I don't know if there's a way to make it work, maybe you can use the older package picamera 1.13
Upvotes: 0
Reputation: 1
I had the same error.
Unable to locate package python3-picamera2
sudo apt install -y python3-picamera2
this package is not installed in UNIX
Upvotes: 0
Reputation: 206
I had to reload the system wide packages installed from apt in to my venv to make it available in there. first deactivate and head in to your repo and then reload the packages with:
python3 -m venv --system-site-packages myenv
activate your venv and check with pip list
if the package is there now.
Upvotes: 1
Reputation: 11
I had the same error. I resolved running: /usr/bin/python3 ./your_script.py
instead of python ./your_script.py
.
The problem was that my default python was /home/pi/miniconda3/bin/python but the command sudo apt install -y python3-picamera2
installs the package for /usr/bin/python3. This at least what I understood.
Upvotes: 1