Skip to content

UnicodeDecodeError from juliacall IPython extension#679

@MilesCranmer

Description

@MilesCranmer

Affects: JuliaCall

Describe the bug
Various users have reported stray UnicodeDecodeErrors when using PySR (=>juliacall) in a Jupyter session:

I think all of these users were on Windows. The error looks like this:

Errorincallback_flush_stdio (forpost_execute), withargumentsargs (),kwargs{}: ---------------------------------------------------------------------------UnicodeDecodeErrorTraceback (mostrecentcalllast) File~/.julia/packages/PythonCall/avYrV/src/JlWrap/any.jl:262, in__call__(self, *args, **kwargs) 260returnValueBase.__dir__(self) +self._jl_callmethod($(pyjl_methodnum(pyjlany_dir))) 261def__call__(self, *args, **kwargs): --> [262](~/.julia/packages/PythonCall/avYrV/src/JlWrap/any.jl:262) returnself._jl_callmethod($(pyjl_methodnum(pyjlany_call)), args, kwargs) 263def__bool__(self): 264returnTrueUnicodeDecodeError: 'utf-8'codeccan'tdecodebyte0xe2inposition4095: unexpectedendofdata

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.

cc @cjdoris - any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions