1

I am using some legacy code from python2 that has to work with python3. So far so good, most of the things work as they should. However I get the most vage error from a library called lxml.

In my understanding this is a library that binds to a binary program written in c.

The problem comes from this piece of code:

 with etree.xmlfile(self.temp_file, encoding='utf-8') as xf:
        with xf.element('{http://www.opengis.net/citygml/2.0}CityModel', nsmap=nsmap):
            with open(input_gml, mode='rb') as f:
                context = etree.iterparse(f)
                for action, elem in context:
                    if action == 'end' and elem.tag == '{http://www.opengis.net/citygml/2.0}cityObjectMember':
                        # Duplicate feature and subfeatures
                        self.duplicateFeature(xf, elem)

                        # Clean up the original element and the node of its previous sibling
                        # (https://www.ibm.com/developerworks/xml/library/x-hiperfparse/)
                        elem.clear()
                        while elem.getprevious() is not None:
                            del elem.getparent()[0]

                del context

        xf.flush()

It processes this xml file. And gets the following error:

    Traceback (most recent call last):
  File "/usr/local/bin/stetl", line 4, in <module>
    __import__('pkg_resources').run_script('Stetl==2.0', 'stetl')
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 666, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1446, in run_script
    exec(code, namespace, namespace)
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/EGG-INFO/scripts/stetl", line 43, in <module>
    main()
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/EGG-INFO/scripts/stetl", line 36, in main
    etl.run()
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/stetl/etl.py", line 157, in run
    chain.run()
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/stetl/chain.py", line 172, in run
    packet = self.first_comp.process(packet)
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/stetl/component.py", line 213, in process
    packet = self.next.process(packet)
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/stetl/component.py", line 213, in process
    packet = self.next.process(packet)
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/stetl/component.py", line 213, in process
    packet = self.next.process(packet)
  File "/usr/local/lib/python3.6/site-packages/Stetl-2.0-py3.6.egg/stetl/component.py", line 199, in process
    packet = self.invoke(packet)
  File "/app/bgt/etl/stetlbgt/subfeaturehandler.py", line 144, in invoke
    del context
  File "src/lxml/serializer.pxi", line 925, in lxml.etree.xmlfile.__exit__
  File "src/lxml/serializer.pxi", line 1263, in lxml.etree._IncrementalFileWriter._close
  File "src/lxml/serializer.pxi", line 1269, in lxml.etree._IncrementalFileWriter._handle_error
  File "src/lxml/serializer.pxi", line 199, in lxml.etree._raiseSerialisationError
lxml.etree.SerialisationError: unknown error -2029930774

I'm not sure what's going wrong here. It seems that something is wrong with some weird encoded character.

How to debug this?

botenvouwer
  • 4,334
  • 9
  • 46
  • 75
  • you should install import openpyxl please ref: https://stackoverflow.com/questions/36657288/copy-pandas-dataframe-to-excel-using-openpyxl – Bo Zhang Nov 27 '19 at 02:29

0 Answers0