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

泄露秘密 提交于 2019-12-13 04:22:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!