Skip to content

Conversation

@HirotsuguMINOWA
Copy link

This was fixed for a hang up at natsort sort func when opening file paths include '@' symbol.

MacOS file system can have '@' symbol inside a file path. But conventional labelme occurred exception due to that.

@wkentaro
Copy link
Owner

wkentaro commented Oct 7, 2025

how do you get '@' in file path? (I use macOS too)

@HirotsuguMINOWA
Copy link
Author

We can use the “@” symbol as same as normal symbols (eg. _, - and so on) unconsciously within file paths. (APFS(Apple File System) may be enable to use '@' in a file path).

I used '@' in a directory path "Google Drive - [email protected]", which occurred the exception.

For example in your terminal, input "touch ~/@.txt" which will make a file "@.txt" in your home folder.

@wkentaro
Copy link
Owner

wkentaro commented Oct 7, 2025

so your only example is Google Drive?

@HirotsuguMINOWA
Copy link
Author

HirotsuguMINOWA commented Oct 7, 2025

This problem may be caused from NFC/NFD or multibyte characters (, I change my opinion).

You know that だ is recorded with た+" in macOS of NFD.

####### I invested some some cases.

# RClone(=connected to CloudStorage(GDrive)) + tmp_imgs -> OK (Succeeded to open a dir with images)
~/rclone_gdrive_research/tmp_imgs/[imgs+jsons]

# RClone(GDrive) + きずあり -> Hang up
~/rclone_gdrive_research/きずあり/[imgs+jsons]

# Local FS + 名称未設定フォルダ -> Hang up
~/名称未設定フォルダ/[imgs+jsons]

# Local FS + きずあり -> Hang up
~/きずあり/[imgs+jsons]

# Local FS + あいう -> OK
~/あいう/[imgs+jsons]
Error msgs
2025-10-08 01:46:20.388 | INFO     | labelme.config:get_config:66 - Loading config file from: /Users/account_me/.labelmerc
2025-10-08 01:46:20.722 | DEBUG    | labelme.widgets.canvas:set_ai_model_name:140 - Setting AI model to 'sam2:latest'
2025-10-08 01:46:26.662 | CRITICAL | labelme.__main__:_handle_exception:84 - Traceback (most recent call last):
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/labelme/app.py", line 2136, in openDirDialog
    self.importDirImages(targetDirPath)
    ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/labelme/app.py", line 2185, in importDirImages
    filenames = self.scanAllImages(dirpath)
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/labelme/app.py", line 2217, in scanAllImages
    images = natsort.os_sorted(images)
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/natsort.py", line 839, in os_sorted
    return sorted(seq, reverse=reverse, key=os_sort_keygen(key))
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/utils.py", line 341, in natsort_key
    return string_func(val)
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/utils.py", line 552, in <lambda>
    return lambda x: tuple(map(str_split, path_splitter(x)))
                     ~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/utils.py", line 523, in func
    return final_transform(g, original)  # Apply the final transform.
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/utils.py", line 776, in func
    return tuple(split_val)
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/utils.py", line 577, in sep_inserter
    first = next(iterator)
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/compat/fastnumbers.py", line 74, in <genexpr>
    return (fast_int(y, key=on_fail) for y in x)
            ~~~~~~~~^^^^^^^^^^^^^^^^
  File "/Users/account_me/.local/pipx/.cache/a08b10f0b458157/lib/python3.13/site-packages/natsort/compat/fake_fastnumbers.py", line 116, in fast_int
    return _uni(x, key(x)) if len(x) == 1 else key(x)
                                               ~~~^^^
OSError: [Errno 22] Invalid argument

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants