Skip to content

TypeError: expected str, bytes or os.PathLike object, not list #637

Description

@gboscagli

Hi all,
first of all, I want to express my gratitude for the universe you built around single-cell data analysis.
I'm moving to SpatialData tool and immediately found a problem reproducing this tutorial. I tried to create the path using os, Pathlib or even a list: the issue still arises. I just downloaded the zarr store as indicated in the tutorial, I just changed the tutorial_data folder name because I already had another store named like that.

{
	"name": "TypeError",
	"message": "expected str, bytes or os.PathLike object, not list",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[13], line 4
      2 cosmx_dir = os.path.join(os.path.abspath(os.curdir), \"tutorial_data_sd\", \"nanostring_data\", \"data.zarr\")
      3 type(cosmx_dir)
----> 4 sdata = SpatialData.read(\"tutorial_data_sd/nanostring_data/data.zarr\")

File c:\\Users\\Gabriele\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\spatialdata\\_core\\spatialdata.py:1160, in SpatialData.read(file_path, selection)
   1144 \"\"\"
   1145 Read a SpatialData object from a Zarr storage (on-disk or remote).
   1146 
   (...)
   1156 The SpatialData object.
   1157 \"\"\"
   1158 from spatialdata import read_zarr
-> 1160 return read_zarr(file_path, selection=selection)

File c:\\Users\\Gabriele\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\spatialdata\\_io\\io_zarr.py:80, in read_zarr(store, selection)
     78 f_elem = group[subgroup_name]
     79 f_elem_store = os.path.join(f_store_path, f_elem.path)
---> 80 element = _read_multiscale(f_elem_store, raster_type=\"image\")
     81 images[subgroup_name] = element
     82 count += 1

File c:\\Users\\Gabriele\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\spatialdata\\_io\\io_raster.py:70, in _read_multiscale(store, raster_type, fmt)
     68 encoded_ngff_transformations = multiscales[0][\"coordinateTransformations\"]
     69 transformations = _get_transformations_from_ngff_dict(encoded_ngff_transformations)
---> 70 name = os.path.basename(node.metadata[\"name\"])
     71 # if image, read channels metadata
     72 channels: Optional[list[Any]] = None

File c:\\Users\\Gabriele\\AppData\\Local\\Programs\\Python\\Python39\\lib\
tpath.py:216, in basename(p)
    214 def basename(p):
    215     \"\"\"Returns the final component of a pathname\"\"\"
--> 216     return split(p)[1]

File c:\\Users\\Gabriele\\AppData\\Local\\Programs\\Python\\Python39\\lib\
tpath.py:185, in split(p)
    180 def split(p):
    181     \"\"\"Split a pathname.
    182 
    183     Return tuple (head, tail) where tail is everything after the final slash.
    184     Either part may be empty.\"\"\"
--> 185     p = os.fspath(p)
    186     seps = _get_bothseps(p)
    187     d, p = splitdrive(p)

TypeError: expected str, bytes or os.PathLike object, not list"
}

Activity

  1. gboscagli commented on Jul 16, 2024

    @gboscagli
    Author

    Now I managed to correctly open the zarr store. It seems it was a problem with / character in Windows machine, as pinpointed in this issue inside spatialdata-io Github.
    I'm closing this, thank you!

  2. LucaMarconato commented on Jul 16, 2024

    @LucaMarconato
    Member

    Thank you for the feedback and glad that you fixed the issue 😊 We will re-investigate the Windows machine support, tracking this in a new issue: scverse/spatialdata-tutorials#106.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions