简体   繁体   中英

python lxml 3.3.5 - error on loading code - “ValueError: lxml.etree._Element has the wrong size, try recompiling”

I installed lxml 3.3.5 through pip. Now I have problems while running some django tests:

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 71, in execute
    super(Command, self).execute(*args, **options)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/south/management/commands/test.py", line 8, in handle
    super(Command, self).handle(*args, **kwargs)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/core/management/commands/test.py", line 88, in handle
    failures = test_runner.run_tests(test_labels)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/test/runner.py", line 144, in run_tests
    suite = self.build_suite(test_labels, extra_tests)
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/django/test/runner.py", line 63, in build_suite
    tests = self.test_loader.loadTestsFromName(label)
  File "/usr/lib/python2.7/unittest/loader.py", line 91, in loadTestsFromName
    module = __import__('.'.join(parts_copy))
  File "/vagrant/myapp/tests/test_myapp.py", line 12, in <module>
    import dm.xmlsec.binding as xmlsec
  File "/home/vagrant/venv/local/lib/python2.7/site-packages/dm/xmlsec/binding/__init__.py", line 2, in <module>
    from _xmlsec import *
  File "etreepublic.pxd", line 33, in init dm.xmlsec.binding._xmlsec (src/_xmlsec.c:9587)
ValueError: lxml.etree._Element has the wrong size, try recompiling

As the traceback show, it fails while loading code. If I try to do the import from the python shell, it fails the first time:

In [1]: import dm.xmlsec.binding as xmlsec
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-74e93bb8b8dd> in <module>()
----> 1 import dm.xmlsec.binding as xmlsec

/home/vagrant/venv/local/lib/python2.7/site-packages/dm/xmlsec/binding/__init__.py in <module>()
      1 # Copyright (C) 2012 by Dr. Dieter Maurer <dieter@handshake.de>; see 'LICENSE.txt' for details
----> 2 from _xmlsec import *
      3 
      4 def dsig(tag):
      5   """`lxml` tag designator for *tag* in DSig namespace."""

/vagrant/etreepublic.pxd in init dm.xmlsec.binding._xmlsec (src/_xmlsec.c:9587)()

ValueError: lxml.etree._Element has the wrong size, try recompiling

In [2]: import dm.xmlsec.binding as xmlsec

any help on it?

Try running this:

pip install -I --no-cache lxml==3.3.5
pip uninstall -y dm.xmlsec.binding
pip install --no-cache dm.xmlsec.binding

I've run into problems when dm.xmlsec.binding is installed before lxml or if lxml changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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