简体   繁体   English

无法在 python 中使用 gphoto2 打开相机

[英]Could not open camera using gphoto2 in python

I try to control a Sony Alpha using Python/gphoto2 on a Raspberry PI.我尝试在 Raspberry PI 上使用 Python/gphoto2 控制 Sony Alpha。 I've tried a number of python bindings (python-gphoto2, gphoto2-cffi, ...) but they all fail at the instruction to create a camera object (eg. my_cam = gphoto.Camera()) with the error:我已经尝试了许多 python 绑定(python-gphoto2,gphoto2-cffi,...),但它们都在创建相机 object 的指令中失败(例如 my_cam = gphoto.Camera()),并出现错误:

"Could not claim interface 0 (Device or resource busy). Make sure no other program (gvfs-gphoto2-volume-monitor) or kernel module (such as sdc2xx, stv680, spca50x) is using the device and you have read/write access to the device." “无法声明接口 0(设备或资源繁忙)。确保没有其他程序(gvfs-gphoto2-volume-monitor)或 kernel 模块(例如 sdc2xx、stv680、spca50x)正在使用该设备并且您具有读/写访问权限到设备。”

We tried to kill background programs, make sure the kernel modules are not running, install the latest versions of the libraries and python packages, ... but could not get rid of the error.我们试图杀死后台程序,确保 kernel 模块没有运行,安装最新版本的库和 python 包,......但无法摆脱错误。 Furthermore C code using libgphoto2 works fine so it's not likely that the resource is really busy.此外,使用 libgphoto2 的 C 代码工作正常,因此资源不太可能真的很忙。 We suspect the problem is missing USB libs in the python packages, and have tried to install libusb-dev, ... but it doesn't help.我们怀疑问题是缺少 python 软件包中的 USB 库,并尝试安装 libusb-dev,......但它没有帮助。

Any suggestions what else we should try?任何建议我们还应该尝试什么? Thanks.谢谢。

You mentioned trying python-gphoto2.你提到尝试 python-gphoto2。 I'm the author of that package.我是那个 package 的作者。 Assuming you have installed it successfully then I'd try the list-cameras.py example program.假设您已成功安装它,那么我将尝试list-cameras.py示例程序。 It should list any cameras recognised by libgphoto2 that are connected and switched on.它应该列出所有被 libgphoto2 识别的已连接并打开的相机。

If C programs are working but Python ones aren't you could check that they're using the same versions of libgphoto2.如果 C 程序正在运行但 Python 程序不是,您可以检查它们是否使用相同版本的 libgphoto2。 Try ldd on the C program's executable and on one of the python-gphoto2 compiled modules, eg /usr/local/lib/python3.5/dist-packages/gphoto2/_camera.cpython-35m-arm-linux-gnueabihf.so .在 C 程序的可执行文件和 python-gphoto2 编译模块之一上尝试ldd ,例如/usr/local/lib/python3.5/dist-packages/gphoto2/_camera.cpython-35m-arm-linux-gnueabihf.so

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

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