SOLVED: Scripting question on library importing

I’m working on a rather complex project (at least for me).
It consists of @keithlostracco 's TopArray and a scriptOp, and @imihailidis venv builder.

I had constructed a pose classifier and it was working great. Saved it. Rebooted.
Not working at all, and Im getting these odd errors that I cant seem to sort out, it seem to have to do with importing libraries. the error is:

DAT compile error: /YoloV8DetectionCudatop/utils
Traceback (most recent call last):
  File "/YoloV8DetectionCudatop/utils", line 1
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\keras\__init__.py", line 21
    from keras import models
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\keras\models\__init__.py", line 18
    from keras.engine.functional import Functional
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\keras\engine\functional.py", line 24
    import tensorflow.compat.v2 as tf
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\__init__.py", line 51
    from ._api.v2 import compat
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\_api\v2\compat\__init__.py", line 37
    from . import v1
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\_api\v2\compat\v1\__init__.py", line 31
    from . import compat
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\_api\v2\compat\v1\compat\__init__.py", line 37
    from . import v1
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\_api\v2\compat\v1\compat\v1\__init__.py", line 48
    from tensorflow._api.v2.compat.v1 import lite
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\_api\v2\compat\v1\lite\__init__.py", line 9
    from . import experimental
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\_api\v2\compat\v1\lite\experimental\__init__.py", line 8
    from . import authoring
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\_api\v2\compat\v1\lite\experimental\authoring\__init__.py", line 8
    from tensorflow.lite.python.authoring.authoring import compatible
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\lite\python\authoring\authoring.py", line 43
    from tensorflow.lite.python import convert
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\lite\python\convert.py", line 27
    from tensorflow.lite.python import util
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\tensorflow\lite\python\util.py", line 52
    from jax import xla_computation as _xla_computation
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\jax\__init__.py", line 80
    from jax._src.api import effects_barrier as effects_barrier
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\jax\_src\api.py", line 39
    from jax._src import stages
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\jax\_src\stages.py", line 50
    from jax._src.interpreters import mlir
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\jax\_src\interpreters\mlir.py", line 47
    from jax._src.interpreters import partial_eval as pe
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\jax\_src\interpreters\partial_eval.py", line 29
    from jax._src import api_util
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\jax\_src\api_util.py", line 27
    from jax._src.abstract_arrays import numpy_scalar_types
    r = previousimport(*args, **kw)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\venvBuilderTD\venv-test\Lib\site-packages\jax\_src\abstract_arrays.py", line 53
    core.pytype_aval_mappings[np.ma.MaskedArray] = masked_array_error
                              ^^^^^
AttributeError: partially initialized module 'numpy' has no attribute 'ma' (most likely due to a circular import). Did you mean: 'max'?

I guess my question is, for instance, if I import numpy in one text DAT where there is some python, do I need to import it again in the other textDAT? it seems like its a bit circular at this point and Im a little lost. Any help is appreciated.

Relpying to myself here.
I had a DAT text chop named ‘utils’ that I was referencing in another DAT text, but for some reason it was showing a dashed ‘reference’ connection back to the ScriptOp TOP. Changing the name text DAT seemed to have fixed as far as I can tell.

I’m curious if anyone knows why though - is there something behind the scenes where we should have a text DAT named utils?
Error:
image
Fixed:

TouchDesigner import statement is not the native python importer.

When you have a DAT of a specific name, it’s added as a module to the search path.

So, a DAT named utils, will be found and imported when you call from another script import utils.

Your python library is probably trying to import utils, but instead of finding the library it’s looking for, it’s importing your TouchDesigner utils DAT.

You could rename it to myUtils to avoid the issue.

Try and import myUtils from another DAT, and you will notice that it does work.

Thanks Michel, my biggest issue was not realizing there was a ‘utils’ DAT somewhere else! I won’t soon forget that :wink: