Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPython shell command failure #37

Open
tbirdso opened this issue Jun 3, 2023 · 0 comments
Open

IPython shell command failure #37

tbirdso opened this issue Jun 3, 2023 · 0 comments

Comments

@tbirdso
Copy link
Contributor

tbirdso commented Jun 3, 2023

Overview

Attempting to run ngff-zarr from an IPython cell in Jupyter Notebook yields an error.

Steps to Reproduce

In a Jupyter Notebook cell:

!ngff-zarr -i "path/to/image.nii.gz" -o "path/to/image.zarr"

Expected behavior

CLI runs and OME-Zarr image is generated successfully

Observed behavior

Traceback (most recent call last):
  File "C:\venvs\venv-itk\lib\site-packages\rich\live.py", line 122, in start
    self.refresh()
  File "C:\venvs\venv-itk\lib\site-packages\rich\live.py", line 241, in refresh
    with self.console:
  File "C:\venvs\venv-itk\lib\site-packages\rich\console.py", line 864, in __exit__
    self._exit_buffer()
  File "C:\venvs\venv-itk\lib\site-packages\rich\console.py", line 822, in _exit_buffer
    self._check_buffer()
  File "C:\venvs\venv-itk\lib\site-packages\rich\console.py", line 2027, in _check_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
  File "C:\venvs\venv-itk\lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_render
    term.write_styled(text, style)
  File "C:\venvs\venv-itk\lib\site-packages\rich\_win32_console.py", line 442, in write_styled
    self.write_text(text)
  File "C:\venvs\venv-itk\lib\site-packages\rich\_win32_console.py", line 403, in write_text
    self.write(text)
  File "C:\Users\tom.birdsong\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: character maps to <undefined>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\tom.birdsong\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\tom.birdsong\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\venvs\venv-itk\Scripts\ngff-zarr.exe\__main__.py", line 7, in <module>
  File "C:\venvs\venv-itk\lib\site-packages\ngff_zarr\cli.py", line 192, in main
    with Live(initial, console=console) as live:
  File "C:\venvs\venv-itk\lib\site-packages\rich\live.py", line 166, in __enter__
    self.start(refresh=self._renderable is not None)
  File "C:\venvs\venv-itk\lib\site-packages\rich\live.py", line 128, in start
    self.stop()
  File "C:\venvs\venv-itk\lib\site-packages\rich\live.py", line 147, in stop
    with self.console:
  File "C:\venvs\venv-itk\lib\site-packages\rich\console.py", line 864, in __exit__
    self._exit_buffer()
  File "C:\venvs\venv-itk\lib\site-packages\rich\console.py", line 822, in _exit_buffer
    self._check_buffer()
  File "C:\venvs\venv-itk\lib\site-packages\rich\console.py", line 2027, in _check_buffer
    legacy_windows_render(buffer, LegacyWindowsTerm(self.file))
  File "C:\venvs\venv-itk\lib\site-packages\rich\_windows_renderer.py", line 17, in legacy_windows_render
    term.write_styled(text, style)
  File "C:\venvs\venv-itk\lib\site-packages\rich\_win32_console.py", line 442, in write_styled
    self.write_text(text)
  File "C:\venvs\venv-itk\lib\site-packages\rich\_win32_console.py", line 403, in write_text
    self.write(text)
  File "C:\Users\tom.birdsong\AppData\Local\Programs\Python\Python310\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-2: character maps to <undefined>

Additional Notes

Copying and pasting the same command into a shell outside of Jupyter Notebook results in expected execution:

ngff-zarr -i "path/to/image.nii.gz" -o "path/to/image.zarr"
╭─────────────────────────────────────────────────── NGFF OME-Zarr ────────────────────────────────────────────────────╮
│   4/4 0:00:14 Writing scales ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:00:00                                   │
╰───────────────────────────────────────────────────── generation ─────────────────────────────────────────────────────╯
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

No branches or pull requests

1 participant