RESOLVED:TD instantly crashes when importing python module

I’m trying to get the Axidraw API to run inside of TD, but the moment I type import pyaxidraw from axidraw TD instantly disappears without any trace of what went wrong.

https://axidraw.com/doc/py_api/#about-axidraw

it goes wrong the moment the axidraw.py script imports any of the following dependencies.

import ebb_serial  # Requires v 0.13 in plotink    https://github.com/evil-mad/plotink
import ebb_motion  # Requires v 0.16 in plotink
import plot_utils  # Requires v 0.15 in plotink
import axidraw_conf  # Some settings can be changed here.

from axidraw_options import common_options, versions

try:
    from plot_utils_import import from_dependency_import # plotink
    simplepath = from_dependency_import('ink_extensions.simplepath')
    simplestyle = from_dependency_import('ink_extensions.simplestyle')
    cubicsuperpath = from_dependency_import('ink_extensions.cubicsuperpath')
    simpletransform = from_dependency_import('ink_extensions.simpletransform')
    inkex = from_dependency_import('ink_extensions.inkex')

except:
    import simplepath
    import simplestyle
    import cubicsuperpath
    import simpletransform
    import inkex

import axidraw_svg_reorder

from lxml import etree

Does anyone have an idea how I could at least get a crash report or something like that?

build 2020.20020 Windows.

Nasty. If you can wrap all necessary dependencies up into a zip so that it’s just a simple decompress and run to test, send it to support@derivative.ca.

Sure thing! Thanks so much Ivan, glad to have a wizard like yourself on the other end :slight_smile:

I appreciate the compliment :slight_smile: But it’s the C++ team that will have to look at why it’s crashing. That’s outside my jurisdiction.

1 Like

So it’s exiting intentionally due to a failed import.
I’ve changed it in the next build, but you can do it manually by circumventing the exit method:

sys.exit = lambda *a : print(‘System exit requested with arguments:’, *a)

Once you have that, the error becomes:

python >>> from pyaxidraw import axidraw

The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension.Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml

Technical details:
cannot import name 'etree' from 'lxml' (C:/Users/Rob/Downloads/t2/site-packages\lxml\__init__.py)
System Exit Requested with arguments:
The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension.Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml

Technical details:
cannot import name 'etree' from 'lxml' (C:/Users/Rob/Downloads/t2/site-packages\lxml\__init__.py)
System Exit Requested with arguments:
ImportError: cannot import name 'etree' from 'lxml' (C:/Users/Rob/Downloads/t2/site-packages\lxml\__init__.py)

Does installing those modules now fix the issue?

Hey @rob,

Thanks for looking into this.

I’ve uninstalled and installed lxml using pip, and looking at the file structure I see etree.h as a file. TD still crashes though.

Only typing

import lxml

doesn’t show any errors btw.

Ok, currently trying some things, re-installing the same version of python as the one in TD might help.

Re-installing python fixed the issue :slight_smile: I guess it had issues since the version of python I had associated with pip was a different version than what TD uses internally. Axidraw is moving along with the mouse and looking happy!

Great to hear!
Yes, definitely we recommend installing same version of python as TouchDesigner.
For your current build its 3.7

Cheers,
Rob.

Just to be sure though, you mentioned TouchDesigner still crashing,
is that after overriding the sys.exit() call ?
That overriding should be done first from anywhere, including the textport or a start script in a DAT.

No adding the sys.exit() call worked fine, first time I didn’t notice quote symbols don’t copy well off the derivate forum.

Okay great. It will be overridden automatically in the next posted build.
Cheers