tlambert03 / nd2

Full-featured nd2 (Nikon NIS Elements) file reader for python. Outputs to numpy, dask, and xarray. Exhaustive metadata extraction
https://tlambert03.github.io/nd2
BSD 3-Clause "New" or "Revised" License
54 stars 15 forks source link

Error with saving nd2 file as ome-tiff file #223

Closed BornKrefeld closed 6 months ago

BornKrefeld commented 6 months ago

Description

My Intention was save an nd2 file to an ome-tiff file. There was following error message related to a miss file tlz

What I Did

coding

#read nd2 and save as ome_types
import nd2
import ome_types

# or open a file with nd2.ND2File
f = nd2.ND2File('24_02_22_ecoliatcc25922_growthonchip_4chips_xy001.nd2')

with nd2.ND2File ( '24_02_22_ecoliatcc25922_growthonchip_4chips_xy001.nd2' ) as myfile:
  myfile.write_tiff ( 'my_file.ome.tiff', progress = True )

f.close()           # don't forget to close when not using a context manager!
f.closed            # boolean, whether the file is closed

Paste the command(s) you ran and the output. If there was a crash, please include the traceback here.

Error message

C:\Users\Born\venv\Scripts\python.exe "C:\Users\Born\PycharmProjects\python bio process Pims_DA_NA\DS_ND2 Data save to OME_Tiff.py" 
Traceback (most recent call last):
  File "C:\Users\Born\PycharmProjects\python bio process Pims_DA_NA\DS_ND2 Data save to OME_Tiff.py", line 3, in <module>
    import ome_types
  File "C:\Users\Born\venv\Lib\site-packages\ome_types\__init__.py", line 13, in <module>
    from ome_types import model
  File "C:\Users\Born\venv\Lib\site-packages\ome_types\model\__init__.py", line 9, in <module>
    from ome_types._autogenerated.ome_2016_06 import *  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Born\venv\Lib\site-packages\ome_types\_autogenerated\ome_2016_06\__init__.py", line 1, in <module>
    from ome_types._autogenerated.ome_2016_06.affine_transform import (
  File "C:\Users\Born\venv\Lib\site-packages\ome_types\_autogenerated\ome_2016_06\affine_transform.py", line 1, in <module>
    from ome_types._mixins._base_type import OMEType
  File "C:\Users\Born\venv\Lib\site-packages\ome_types\_mixins\_base_type.py", line 25, in <module>
    from ome_types.units import add_quantity_properties
  File "C:\Users\Born\venv\Lib\site-packages\ome_types\units.py", line 6, in <module>
    import pint
  File "C:\Users\Born\venv\Lib\site-packages\pint\__init__.py", line 28, in <module>
    from .formatting import formatter, register_unit_format
  File "C:\Users\Born\venv\Lib\site-packages\pint\formatting.py", line 20, in <module>
    from .babel_names import _babel_lengths, _babel_units
  File "C:\Users\Born\venv\Lib\site-packages\pint\babel_names.py", line 11, in <module>
    from .compat import HAS_BABEL
  File "C:\Users\Born\venv\Lib\site-packages\pint\compat.py", line 206, in <module>
    from dask import array as dask_array
  File "C:\Users\Born\venv\Lib\site-packages\dask\array\__init__.py", line 4, in <module>
    from dask.array import backends, fft, lib, linalg, ma, overlap, random
  File "C:\Users\Born\venv\Lib\site-packages\dask\array\backends.py", line 8, in <module>
    from dask.array.core import Array
  File "C:\Users\Born\venv\Lib\site-packages\dask\array\core.py", line 32, in <module>
    from tlz.curried import pluck
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "C:\Users\Born\venv\Lib\site-packages\tlz\_build_tlz.py", line 82, in exec_module
    submodule = import_module(module_name)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Born\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
AttributeError: 'TlzSpec' object has no attribute '_uninitialized_submodules'

Process finished with exit code 1
tlambert03 commented 6 months ago

i'm honestly not sure... and it's not an nd2 issue, it's an issue with toolz (imported by dask). Did you try creating a new environment by chance?

BornKrefeld commented 6 months ago

Issue was solved with update Toolz to 0.12.1