问题
I'm trying to invoke the gsutil command from a cell in a Jupyter notebook, using the bash cell magic %%bash, as such:%%bash
gsutil
However I am receiving the following output:bash: line 1: gsutil: command not found
On the other hand, using the exclamation mark syntax gives me the expected result:!gsutil
Gives...Usage: gsutil [-D] [-DD] [-h header]... [-m] [-o] [-q] [command [opts...] args...]
Available commands:
acl Get, set, or change bucket and/or object ACLs
cat Concatenate object content to stdout......
The ! syntax doesn't support multi-line commands, and even if it did, as I am collaborating with others, I need the %%bash syntax to work for me.
Can anyone enlighten me as to what the reason behind this is and how I can go about solving it?
Thanks in advance.
回答1:
I got around this by using the %%cmd magic instead, which I was unaware of. I'll still have to do some tweaking of the bash commands as there are some slight inconsistencies, but still better than nothing.
回答2:
It sounds like your PATH environment variable might be different in the two environments. What do you get as the output from
!echo $PATH
and
%%bash
echo $PATH
?
来源:https://stackoverflow.com/questions/51548928/bash-cell-magic-giving-command-not-found-error-in-jupyter-notebook-windo