欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > Raspbian命令行安装指定版本picamera2

Raspbian命令行安装指定版本picamera2

2024/10/24 17:28:24 来源:https://blog.csdn.net/lida2003/article/details/140005672  浏览:    关键词:Raspbian命令行安装指定版本picamera2

Raspbian命令行安装指定版本picamera2

  • 1. 源由
  • 2. 卸载、升级、安装
    • 2.1 查看
    • 2.2 卸载
    • 2.3 升级
    • 2.4 安装
  • 3. OS指定版本安装
  • 4. 补充 - 安装异常

1. 源由

  • OV5647与树莓派bullseye 64bit的兼容性问题
  • Can’t access video WebGUI #234

上面的问题,主要还是树莓派上查找摄像头设备出现异常的问题。目前基本已经定位到是picamera2的兼容性问题。

因此,我们需要了解如何卸载、安装、安装指定版本的picamera2,进而再指定OS下安装特定版本,从而解决上述问题。

2. 卸载、升级、安装

注:pip 可以替换为pip3,具体看python当前环境,本机默认是python3。

2.1 查看

$ pip list | grep picamera2

2.2 卸载

$ pip uninstall picamera2

2.3 升级

$ python -m pip install --upgrade pip

2.4 安装

$ pip install picamera2

安装指定版本:

$ pip install picamera2==<版本号>

3. OS指定版本安装

$ nano ./install_picamera2.sh
$ chmod +x install_picamera2.sh
$ cat ./install_picamera2.sh
#!/bin/bash# Function to detect the OS version
detect_os() {if [ -f /etc/os-release ]; then. /etc/os-releaseOS=$NAMEVERSION=$VERSION_IDelseecho "OS detection not supported. Exiting."exit 1fi
}# Function to install picamera2 for Bullseye
install_bullseye() {echo "Installing picamera2=0.3.12 for Bullseye..."pip install picamera2==0.3.12
}# Function to install picamera2 for Bookworm
install_bookworm() {echo "Installing picamera2 for Bookworm..."pip install picamera2
}# Main script
detect_osecho "Detected OS: $OS"
echo "Detected Version: $VERSION"# picamera2 needs libcap
sudo apt-get install libcap-devif [[ $OS == "Debian GNU/Linux" || $OS == "Raspbian GNU/Linux" ]]; thencase $VERSION in"11")install_bullseye;;"12")install_bookworm;;*)echo "Unsupported Debian/Raspbian version: $VERSION. Exiting."exit 1;;esac
elseecho "Unsupported OS: $OS. Exiting."exit 1
fiecho "Installation complete."

4. 补充 - 安装异常

 Preparing metadata (setup.py) ... errorerror: subprocess-exited-with-error× python setup.py egg_info did not run successfully.│ exit code: 1╰─> [1 lines of output]You need to install libcap development headers to build this module[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed× Encountered error while generating package metadata.
╰─> See above for output.

需要提前安装 libcap 开发头文件:

$ sudo apt-get install libcap-dev

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com