8

I'm currently running Jupyter Notebook (Windows 7) within a Conda environment using Python 3.6.4 and my current version of Jupyter Notebook is 5.6.0. I came across the following article: Using Git Bash in Jupyter Notebook on Windows , that explains how to change the default shell within Jupyter Notebook to Bash by changing the config "C.NotebookApp.terminado_settings = {'shell_command': ['C:\Program Files\Git\bin\bash.exe']}. I've tried multiple different options for the path to bash, including just the name 'bash', with no success.

Python and Jupyter version Python and Jupyter version:

Juypter Notebook shell not changed Jupyter Notebook: Not changed, still using Powershell

I've read up on the Jupyter Notebook: Read the Docs , and made the changes to the jupyter_notebook_config.py found under C:\Users\UserName\.jupyter directory, without any success.

jupter_notebook_config.py terminado configuration

Peter Wilson
  • 1,075
  • 3
  • 14
  • 24

2 Answers2

5

An alternative solution to your problem is to use the Windows Subsystem for Linux (WSL). I am under Windows 10, conda 4.5.11 and Jupyter lab 0.35.3. I have also activated the Windows subsystem for Linux (WSL). Using !wsl you can call the WSL or with %%bash for cell magics. Inside Jupyter Lab I have: enter image description here

is the %%bash cell magic referring to the WSL? According to my tests yes, I can access the same programs and I am taken to the WSL when I run bash.exe from the Conda prompt. There is an integration of the PowerShell prompt to WSL (https://learn.microsoft.com/en-us/windows/wsl/interop). The same seems to work with the conda prompt.

BND
  • 612
  • 1
  • 13
  • 23
2

Here are three options:

  1. If one opens Jupyter notebook via GitBash with jupyter notebook then %%bash magics should work

  2. If one wishes to always be able to run bash within a Jupyter Notebook opened via Anaconda Prompt (similarly using jupyter notebook):

    • Edit the Jupyter Notebook config file:

      • Location can be found via Anaconda Prompt with jupyter --config-dir
      • Open the jupyter_notebook_config.py file in this directory using notepad or an IDE
      • Modify and save with the line of code: c.NotebookApp.terminado_settings = {} pointed instead to your bash executible (e.g.): c.NotebookApp.terminado_settings = { 'shell_command': ['C:\Program Files\Git\bin\bash.exe'] }
    • Edit your system environment variables:

      • Windows Search (with admin rights) > "Edit the System Environment Variables" > Environment Variables > Highlight "path" > Edit > Add a new line with C:\Program Files\Git\bin > OK out of all windows
  3. Set an environment variable in Jupyter Notebook

ENIAC-6
  • 313
  • 8
  • 18