Burp Suite User Forum

Create new post

Jython - ImportError: No module named expatreader

Frantisek | Last updated: Jan 31, 2020 07:51AM UTC

Hi, I would like to use defusedxml package. I am using Jython 2.7.1 standelone and I created virtual pyhton env where I installed defusedxml. I set up in bup extender "folder for loading modules" to - venv/lib/python2.7/site-packages. But it does not work in burp I got exception while importing: from defusedxml import minidom. But it works well outside burp in venv. Does anyone have any ideas why it does not work? Thank you Traceback (most recent call last): File "$HOME/$EXTPATH/burp/beautifier/beautifier.py", line 12, in <module> from defusedxml import minidom File "$HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/minidom.py", line 12, in <module> from . import pulldom as _pulldom File "$HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/pulldom.py", line 12, in <module> from .sax import make_parser File "$HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/sax.py", line 13, in <module> from . import expatreader File "$HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/expatreader.py", line 10, in <module> from xml.sax.expatreader import ExpatParser as _ExpatParser ImportError: No module named expatreader at org.python.core.Py.ImportError(Py.java:334) at org.python.core.imp.import_logic(imp.java:913) at org.python.core.imp.import_module_level(imp.java:970) at org.python.core.imp.importName(imp.java:1057) at org.python.core.ImportFunction.__call__(__builtin__.java:1280) at org.python.core.PyObject.__call__(PyObject.java:450) at org.python.core.__builtin__.__import__(__builtin__.java:1232) at org.python.core.imp.importFromAs(imp.java:1149) at org.python.core.imp.importFrom(imp.java:1124) at defusedxml.expatreader$py.f$0($HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/expatreader.py:60) at defusedxml.expatreader$py.call_function($HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/expatreader.py) at org.python.core.PyTableCode.call(PyTableCode.java:171) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.imp.createFromCode(imp.java:436) at org.python.core.imp.createFromPyClass(imp.java:237) at org.python.core.imp.createFromPyClass(imp.java:205) at org.python.core.imp.loadFromSource(imp.java:657) at org.python.core.imp.find_module(imp.java:551) at org.python.core.PyModule.impAttr(PyModule.java:111) at org.python.core.PyModule.__findattr_ex__(PyModule.java:140) at org.python.core.PyObject.__findattr__(PyObject.java:965) at org.python.core.PyObject.__findattr__(PyObject.java:950) at org.python.core.imp.ensureFromList(imp.java:1016) at org.python.core.imp.ensureFromList(imp.java:990) at org.python.core.imp.import_module_level(imp.java:977) at org.python.core.imp.importName(imp.java:1057) at org.python.core.ImportFunction.__call__(__builtin__.java:1280) at org.python.core.PyObject.__call__(PyObject.java:450) at org.python.core.__builtin__.__import__(__builtin__.java:1232) at org.python.core.imp.importFromAs(imp.java:1149) at org.python.core.imp.importFrom(imp.java:1124) at defusedxml.sax$py.f$0($HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/sax.py:59) at defusedxml.sax$py.call_function($HOME/opt/jython/venv/lib/python2.7/site-packages/defusedxml/sax.py) ...

Hannah, PortSwigger Agent | Last updated: Jan 31, 2020 08:24AM UTC

If you remove the references to expatreader, does your extension load correctly into Burp?

creigelde | Last updated: Aug 13, 2020 09:52AM UTC

You need a file named __init__.py (two underscores on each side) in every folder in the hierarchy. This is what python looks for to know that it should access a particular folder. The files are meant to contain initialization instructions but even if you create them empty this will solve it. To get rid of this error “ImportError: No module named”, you just need to create __init__.py in the appropriate directory and everything will work fine. http://net-informations.com/ql/pya/modules.html

You must be an existing, logged-in customer to reply to a thread. Please email us for additional support.