You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
UnicodeDecodeError from juliacall IPython extension #679
The workaround seems to be to set PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=no before loading. I think it's worth figuring out the root cause of the issue, though.
One quick fix is that we have PYTHON_JULIACALL_AUTOLOAD_IPYTHON_EXTENSION=auto by default, which would get set to no on Windows, or yes on Linux/macOS. Although the downside is this would make notebooks non-reproducible on different operating systems, so it's probably better to fix the root cause.
This is happening in the IPython callback that is called after each cell which flushes stdout and stderr. We redirect these streams so that they are sent to the kernel and so are visible in the notebook (otherwise print doesn't work).
The unexpected end of data makes me think that the redirected stream is being flushed while only part of a UTF-8 character has actually been written to it. Because Python's sys.stdout is a text IO, you write strings to it, and Python strings only accept valid unicode, and so constructing the string to write fails because there is a partial character at the end.
The correct answer is probably to change flush(::PyIO) to not necessarily flush the entire buffer, but to leave any partial character at the end in the buffer until the next flush.
Activity
cjdoris commentedon Sep 27, 2025
This is happening in the IPython callback that is called after each cell which flushes stdout and stderr. We redirect these streams so that they are sent to the kernel and so are visible in the notebook (otherwise
printdoesn't work).The
unexpected end of datamakes me think that the redirected stream is being flushed while only part of a UTF-8 character has actually been written to it. Because Python'ssys.stdoutis a text IO, you write strings to it, and Python strings only accept valid unicode, and so constructing the string to write fails because there is a partial character at the end.The correct answer is probably to change
flush(::PyIO)to not necessarily flush the entire buffer, but to leave any partial character at the end in the buffer until the next flush.fix #679 - defer printing of partial characters at end of buffer when…
fix JuliaPy#679 - defer printing of partial characters at end of buff…