简体   繁体   中英

Bash cell magic (%%) giving “command not found” error in Jupyter notebook (Windows 7)

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.

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.

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

?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM