eclecticiq/OpenTAXII

Packaging issue with pyinstaller

tahirshehram opened this issue · 7 comments

-I've packaged python file using pyinstaller in Ubuntu-18.04 LTS containing below mentioned statement only:

import opentaxii

This packaged exe then raised error:
Traceback (most recent call last):
File "libtaxii/common.py", line 34, in parse
File "src/lxml/etree.pyx", line 3424, in lxml.etree.parse
File "src/lxml/parser.pxi", line 1840, in lxml.etree._parseDocument
File "src/lxml/parser.pxi", line 1866, in lxml.etree._parseDocumentFromURL
File "src/lxml/parser.pxi", line 1770, in lxml.etree._parseDocFromFile
File "src/lxml/parser.pxi", line 1163, in lxml.etree._BaseParser._parseDocFromFile
File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc
File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
File "src/lxml/parser.pxi", line 638, in lxml.etree._raiseParseError
OSError: Error reading file '/tmp/_MEICJe6hi/libtaxii/xsd/TAXII_XMLMessageBinding_Schema.xsd': failed to load external entity "/tmp/_MEICJe6hi/libtaxii/xsd/TAXII_XMLMessageBinding_Schema.xsd"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "test.py", line 3, in
from opentaxii.middleware import create_app
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "/usr/local/lib/python3.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.dict)
File "opentaxii/init.py", line 7, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "/usr/local/lib/python3.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.dict)
File "opentaxii/server.py", line 4, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "/usr/local/lib/python3.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.dict)
File "opentaxii/taxii/services/init.py", line 3, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "/usr/local/lib/python3.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.dict)
File "opentaxii/taxii/services/inbox.py", line 10, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "/usr/local/lib/python3.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.dict)
File "opentaxii/taxii/utils.py", line 9, in
File "", line 983, in _find_and_load
File "", line 967, in _find_and_load_unlocked
File "", line 677, in _load_unlocked
File "/usr/local/lib/python3.7/dist-packages/PyInstaller/loader/pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.dict)
File "opentaxii/taxii/bindings.py", line 45, in
File "libtaxii/validation.py", line 148, in init
File "libtaxii/common.py", line 36, in parse
File "src/lxml/etree.pyx", line 3190, in lxml.etree.XML
File "src/lxml/parser.pxi", line 1877, in lxml.etree._parseMemoryDocument
File "src/lxml/parser.pxi", line 1758, in lxml.etree._parseDoc
File "src/lxml/parser.pxi", line 1068, in lxml.etree._BaseParser._parseUnicodeDoc
File "src/lxml/parser.pxi", line 601, in lxml.etree._ParserContext._handleParseResultDoc
File "src/lxml/parser.pxi", line 711, in lxml.etree._handleParseResult
File "src/lxml/parser.pxi", line 640, in lxml.etree._raiseParseError
File "", line 1
lxml.etree.XMLSyntaxError: Start tag expected, '<' not found, line 1, column 1
[20896] Failed to execute script test

My dependencies are:
altgraph==0.17
anyconfig==0.9.11
blinker==1.4
click==7.1.2
Flask==1.1.2
itsdangerous==1.1.0
Jinja2==2.11.2
libtaxii==1.1.116
lxml==4.5.1
MarkupSafe==1.1.1
opentaxii==0.1.12
PyInstaller==3.6
PyJWT==1.7.1
python-dateutil==2.8.1
pytz==2020.1
PyYAML==5.3.1
six==1.15.0
SQLAlchemy==1.3.17
structlog==20.1.0
Werkzeug==1.0.1

If anyone can help me out here?

traut commented

@tahirshehram did it pack files with extension xsd, like TAXII_XMLMessageBinding_Schema.xsd?

As in aforementioned error, pyinstaller failed to load TAXII_XMLMessageBinding_Schema.xsd

traut commented

@tahirshehram correct. That's why my question is - was it packed together with the code?

@traut
No, it wasn't packaged with TAXII_XMLMessageBinding_Schema.xsd because of which the packaged exe raised unable to read error.
I am not sure what am i missing here, if you can guide?

traut commented

not sure I understand where the issue is. Do you see this error while installing the package via pip? If so, it might be an issue in libtaxii.

I have no experience with pyinstaller, so can't help much.

The issue is closed because of inactivity. The issue could be open again if additional information is provided to justify it is a OpenTAXII bug. A reproducible way to create the bug would help.

Note: pyinstaller is not officially supported and there is no plan for doing it.