I tried using magic command bash in Jupyter notebook in vscode below and it always fails with error below. Other magic commands work with no problem. After some research it seems like it’s the problem of WSL. But I have no idea how to fix it.
%%bash
echo “Hello”
<3>WSL (9) ERROR: CreateProcessEntryCommon:505: execvpe /bin/bash failed 2
<3>WSL (9) ERROR: CreateProcessEntryCommon:508: Create process not expected to return
---------------------------------------------------------------------------
CalledProcessError Traceback (most recent call last)
Cell In[2], line 1
----> 1 get_ipython().run_cell_magic('bash', '', 'echo "Hello"n')
File ~AppDataLocalProgramsPythonPython310libsite- packagesIPythoncoreinteractiveshell.py:2541, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
2539 with self.builtin_trap:
2540 args = (magic_arg_s, cell)
-> 2541 result = fn(*args, **kwargs)
2543 # The code below prevents the output from being displayed
2544 # when using magics with decorator @output_can_be_silenced
2545 # when the last Python token in the expression is a ';'.
2546 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):
File ~AppDataLocalProgramsPythonPython310libsite-packagesIPythoncoremagicsscript.py:155, in ScriptMagics._make_script_magic.<locals>.named_script_magic(line, cell)
153 else:
154 line = script
--> 155 return self.shebang(line, cell)
File ~AppDataLocalProgramsPythonPython310libsite-packagesIPythoncoremagicsscript.py:315, in ScriptMagics.shebang(self, line, cell)
310 if args.raise_error and p.returncode != 0:
311 # If we get here and p.returncode is still None, we must have
312 # killed it but not yet seen its return code. We don't wait for it,
313 # in case it's stuck in uninterruptible sleep. -9 = SIGKILL
314 rc = p.returncode or -9
--> 315 raise CalledProcessError(rc, cell)
CalledProcessError: Command 'b'echo "Hello"n'' returned non-zero exit status 1.
`
I tried using bash magic command in Jupyter notebook in Vscode. Also tried opening the note book in browser.
Hope someone could help point out the issue and fix it. The bash magic command works in Google Colab from my online assignment
New contributor
Jay Huang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.