Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NotImplementedError: AnySimpleType.pytonvalue() not implemented #4

Open
LegionFu opened this issue Aug 30, 2017 · 12 comments
Open

NotImplementedError: AnySimpleType.pytonvalue() not implemented #4

LegionFu opened this issue Aug 30, 2017 · 12 comments

Comments

@LegionFu
Copy link

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?

@FalkTannhaeuser
Copy link
Owner

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
Copy link
Owner

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?

@LegionFu
Copy link
Author

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 (ˉ▽ ̄~))

@FalkTannhaeuser
Copy link
Owner

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...

@LegionFu
Copy link
Author

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

@happycorsair
Copy link

Still exists :(

@iomihai
Copy link

iomihai commented Mar 3, 2018

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.

@happycorsair
Copy link

@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...

@peermaniak
Copy link

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).

@tomdoughty62
Copy link

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

@vivekbdh
Copy link

vivekbdh commented Feb 4, 2019

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

@tsdrm
Copy link

tsdrm commented Mar 19, 2019

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~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants