In a jupyter notebook when trying to run conda or mamba as a magic command, in Windows, it fails. For example
%conda --version
The problem is that in IPython\core\magics\packaging.py, in _get_conda_like_executable there is
match = re.search(
rf"^#\s*cmd:\s*(?P<command>.*{executable})\s[create|install]",
history,
flags=re.MULTILINE,
)
where executable is a Path object. In windows, this gets converted to a string with backslashes. re then tries to treat these backslashes as escape characters and fails. For example, when executable is 'c:\Users\me\mambaforge\envs\myenv\conda' the error will be error: incomplete escape \U at position 28
I believe the fix is to use executable.name instead of executable in the search string. This will emulate previous versions but I don't know if there are other considerations.
In a jupyter notebook when trying to run conda or mamba as a magic command, in Windows, it fails. For example
%conda --versionThe problem is that in IPython\core\magics\packaging.py, in
_get_conda_like_executablethere iswhere
executableis aPathobject. In windows, this gets converted to a string with backslashes.rethen tries to treat these backslashes as escape characters and fails. For example, when executable is 'c:\Users\me\mambaforge\envs\myenv\conda' the error will beerror: incomplete escape \U at position 28I believe the fix is to use
executable.nameinstead ofexecutablein the search string. This will emulate previous versions but I don't know if there are other considerations.