python-onvif-zeep icon indicating copy to clipboard operation
python-onvif-zeep copied to clipboard

NotImplementedError: AnySimpleType.pytonvalue() not implemented

Open LegionFu opened this issue 7 years ago • 12 comments

Here is my code(Run with python 3.6 and python-onvif-0.2.0 ): from onvif import ONVIFCamera, ONVIFError mycam = ONVIFCamera('192.168.1.64', 80, 'admin', 'admin12345', 'C:\ProgramData\Anaconda3\Lib\site-packages\onvif-0.2.0-py3.6.egg\wsdl') media = mycam.create_media_service() media_profile = media.GetProfiles()[0]

And what I get: 1 2

How can i fixed it?

LegionFu avatar Aug 30 '17 12:08 LegionFu

I can not reproduce this problem... Questions:

  • Which camera are you using? I did my tests on a Canon VB-H43.
  • Due to a bug in the upstream project that I have been unable to fix so far, the WSDL files are placed into a wrong destination directory under Windows Anaconda - it is necessary to move the directory from e.g. C:\ProgramData\Anaconda3\wsdl manually to C:\ProgramData\Anaconda3\Lib\site-packages\wsdl respectively C:\ProgramData\Anaconda3\envs\<<<your Python env>>>\Lib\site-packages\wsdl after installation of python-onvif-zeep. Then it should be sufficient to instantiate the Onvif camera using mycam = ONVIFCamera('192.168.1.64', 80, 'admin', 'admin12345') i.e. without the 5th argument.

FalkTannhaeuser avatar Sep 12 '17 18:09 FalkTannhaeuser

Another question: Are you able to run your test with the upstream version under Python 2.7? Since you seem to use Anaconda 3, you could:

  • create a virtual environment for Python 2.7,
  • install the upstream version of python-onvif, e.g. using the command pip install --upgrade https://github.com/quatanium/python-onvif/archive/master.zip into said Python 2.7 environment,
  • manually move the WSDL folder created during the python-onvif installation at the wrong place (e.g. C:\ProgramData\Anaconda3\envs\<<<Python 2.7 env>>>\wsdl) to the right one (e.g. C:\ProgramData\Anaconda3\envs\<<<Python 2.7 env>>>\Lib\site-packages\wsdl).

What happens if you run your test under this setting?

FalkTannhaeuser avatar Sep 12 '17 23:09 FalkTannhaeuser

I have installed python 2.7 , And it running without any problem, So i think this problem has nothing to do with my camera (Actually... i don't know my camera model number (ˉ▽ ̄~))

LegionFu avatar Sep 13 '17 06:09 LegionFu

Did you try with the last version, which can be installed through pip install onvif_zeep and which is supposed to place the wsdl directory into the right destination folder e.g. C:\ProgramData\Anaconda3\Lib\site-packages? With this version, you should be able to do simply mycam = ONVIFCamera('192.168.1.64', 80, 'admin', 'admin12345') i.e. you don't need to pass the wsdl directory as parameter...

FalkTannhaeuser avatar Sep 26 '17 18:09 FalkTannhaeuser

I tried the last version , and initialize an ONVIFCamera instance by mycam = ONVIFCamera('192.168.1.64', 80, 'admin', 'admin12345')

But when i running media_profile = media.GetProfiles() , I got the same error image

LegionFu avatar Sep 27 '17 05:09 LegionFu

Still exists :(

happycorsair avatar Mar 01 '18 20:03 happycorsair

I got around this by using the fix I found here mvantellingen/python-zeep#418

I monkey patched zeep:

import zeep
from onvif import ONVIFCamera, ONVIFService

def zeep_pythonvalue(self, xmlvalue):
    return xmlvalue

zeep.xsd.simple.AnySimpleType.pythonvalue = zeep_pythonvalue

It's not very nice but it works for me.

iomihai avatar Mar 03 '18 19:03 iomihai

@iomihai, thanks a lot! Works like a charm. You've saved tons of my time! Thanks, thanks, thanks!

But anyway, I'll try to investigate this problem later...

happycorsair avatar Mar 04 '18 21:03 happycorsair

Same problem on the onvif GetProfiles() call. Interesting though I have no issues on the Panasonic and Sony cameras, but only on a Honeywell (exactly the same code, zeep version 2.5.0).

peermaniak avatar Apr 30 '18 12:04 peermaniak

Had the same issue on Python3.6.5. Thanks to @iomihai for providing that fix.

tomdoughty62 avatar Jul 05 '18 08:07 tomdoughty62

where to append exactly patch ? I'm simply executing rotate_image.py from example folder and getting above error.

vivekbdh avatar Feb 04 '19 10:02 vivekbdh

I got around this by using the fix I found here mvantellingen/python-zeep#418

I monkey patched zeep:

import zeep
from onvif import ONVIFCamera, ONVIFService

def zeep_pythonvalue(self, xmlvalue):
    return xmlvalue

zeep.xsd.simple.AnySimpleType.pythonvalue = zeep_pythonvalue

It's not very nice but it works for me.

It's simple but so cool~~

tsdrm avatar Mar 19 '19 03:03 tsdrm