Jupyter notebook - Couldn't find program: 'bash'


Did you try what the error message said to try?

i.e. '%%bash' instead of '%bash'

This page seems to indicate that you're going to want two percent signs to utilize the bash script magic.

Edit. Tailored answer to no longer be to specific errawr message. When I run %lsmagic I get the following:


Available line magics:
%alias  %alias_magic  %autocall  %automagic  %autosave  %bookmark  %cd %clear  %cls  %colors  %config  %connect_info  %copy  %ddir  %debug  
%dhist  %dirs  %doctest_mode  %echo  %ed  %edit  %env  %gui  %hist  
%history  %install_default_config  %install_ext  %install_profiles %killbgscripts  %ldir  
%less  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %macro  %magic  
%matplotlib  %mkdir  %more  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2 
%popd  %pprint  %precision  
%profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx 
%reload_ext  %ren  %rep  %rerun  %reset  %reset_selective  %rmdir  %run  %save  %sc  %set_env  %store  %sx  
%system  %tb  %time  %timeit  %unalias  %unload_ext  %who  %who_ls  %whos  %xdel  %xmode

Available cell magics:
%%!  %%HTML  %%SVG  %%bash  %%capture  %%cmd  %%debug  %%file  %%html  %%javascript  
%%latex  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  
%%time  %%timeit  %%writefile

Automagic is ON, % prefix IS NOT needed for line magics.

The following command works:


buruzaemon nailed it.

A. Gordon
Author by

A. Gordon

Updated on June 05, 2022


  • A. Gordon
    A. Gordon almost 2 years

    I'm using a PC with Windows 7 and a Python 3.4 Jupyter notebook from Anaconda3 version 2.3.0.

    I'm attempting to run the cell magic bash command from a Jupyter notebook and am having problems that I imagine others will encounter as well.

    From what I've seen in tutorials, it should be as simple as...


    When I attempt this, I get the error "Couldn't find program: 'bash'". This is true for other bash commands. I have also tried !bash and that has not worked.

    A few strange observations that may help:

    I am able to run bash commands that don't require parameters as long as they are the first line in the cell.

    Volume in drive D is DATA
    Volume Serial Number is XXXX-XXXX
    Directory of D:\...
    05/19/2016  06:25 PM    <DIR>          .

    However if I put a return above the command, it seems to interpret the cell as python and gives the "name 'ls' is not defined" error.

    If I attempt to call the bash line magic command %bash I get the below error:

    'ERROR: Line magic function `%bash` not found (But cell magic `%%bash` exists, did you mean that instead?)'.

    Thanks in advance for any help.

  • A. Gordon
    A. Gordon almost 8 years
    Hi and thanks for the help. I did try %%bash - that was actually what I tried first given that's how it seems it's supposed to work in the tutorials I've seen. Apologies if I didn't make that very clear above. When I try that I get the error "Couldn't find program: 'bash'"