python-onvif 库踩坑

python-onvif 库踩坑

python2环境

时间:2021年6月
操作系统:ubuntu 18.04
参考博客:
https://blog.csdn.net/zong596568821xp/article/details/89644654
使用了conda用于环境隔离
新建环境:

conda create --name py2 python=2.7

使用环境:

conda activate py2

安装onvif包:

pip install onvif

或者源码安装

git clone https://github.com/quatanium/python-onvif
cd python-onvif
python setup.py install

执行样例代码出现如下错误:

Traceback (most recent call last):
  File "pic.py", line 84, in <module>
    continuous_move()
  File "pic.py", line 44, in continuous_move
    mycam = ONVIFCamera('192.168.1.30', 80, 'video', 'hk123456')
  File "/home/lzh/anaconda3/envs/py2/lib/python2.7/site-packages/onvif/client.py", line 258, in __init__
    self.update_xaddrs()
  File "/home/lzh/anaconda3/envs/py2/lib/python2.7/site-packages/onvif/client.py", line 265, in update_xaddrs
    self.devicemgmt  = self.create_devicemgmt_service()
  File "/home/lzh/anaconda3/envs/py2/lib/python2.7/site-packages/onvif/client.py", line 393, in create_devicemgmt_service
    return self.create_onvif_service('devicemgmt', from_template)
  File "/home/lzh/anaconda3/envs/py2/lib/python2.7/site-packages/onvif/client.py", line 362, in create_onvif_service
    xaddr, wsdl_file = self.get_definition(name)
  File "/home/lzh/anaconda3/envs/py2/lib/python2.7/site-packages/onvif/client.py", line 344, in get_definition
    raise ONVIFError('No such file: %s' % wsdlpath)
onvif.exceptions.ONVIFError: Unknown error: No such file: /home/lzh/anaconda3/envs/py2/lib/python2.7/site-packages/wsdl/devicemgmt.wsdl

原因:
wsdl文件夹在安装的时候被复制到了

/home/用户名/anaconda3/envs/py2/wsdl

目录下
解决方法:
复制上述目录的wsdl文件夹到路径

 /home/用户名/anaconda3/envs/py2/lib/python2.7/site-packages/

下即可。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值