[英]How to change Jupyter Notebook (Windows) shell to bash
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.我目前正在使用 Python 3.6.4 在 Conda 环境中运行 Jupyter Notebook(Windows 7),我当前的 Jupyter Notebook 版本是 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.我看到了以下文章: 在 Windows 上的 Jupyter Notebook 中使用 Git Bash ,它解释了如何通过更改配置“C.NotebookApp.terminado_settings = {'shell_command': ['C:\\ Program Files\\Git\\bin\\bash.exe']}。我尝试了多种不同的 bash 路径选项,包括名称“bash”,但都没有成功。
Python and Jupyter version: Python 和 Jupyter 版本:
Jupyter Notebook: Not changed, still using Powershell Jupyter Notebook:未更改,仍在使用 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.我已经阅读了Jupyter Notebook: Read the Docs ,并对 C:\\Users\\UserName\\.jupyter 目录下的 jupyter_notebook_config.py 进行了更改,但没有成功。
An alternative solution to your problem is to use the Windows Subsystem for Linux (WSL).您的问题的另一种解决方案是使用适用于 Linux 的 Windows 子系统 (WSL)。 I am under Windows 10, conda 4.5.11 and Jupyter lab 0.35.3.我在 Windows 10、conda 4.5.11 和 Jupyter lab 0.35.3 下。 I have also activated the Windows subsystem for Linux (WSL).我还为 Linux (WSL) 激活了 Windows 子系统。 Using !wsl
you can call the WSL or with %%bash
for cell magics.使用!wsl
您可以调用 WSL 或使用%%bash
进行单元格魔法。 Inside Jupyter Lab I have:在 Jupyter 实验室内,我有:
is the %%bash cell magic referring to the WSL? %%bash 单元魔术指的是 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.根据我的测试,是的,我可以访问相同的程序,并且当我从 Conda 提示符运行 bash.exe 时,我会被带到 WSL。 There is an integration of the PowerShell prompt to WSL ( https://docs.microsoft.com/en-us/windows/wsl/interop ). PowerShell 提示集成到 WSL ( https://docs.microsoft.com/en-us/windows/wsl/interop )。 The same seems to work with the conda prompt.这似乎适用于 conda 提示。
Here are three options:这里有三个选项:
If one opens Jupyter notebook via GitBash with jupyter notebook
then %%bash
magics should work如果一个人通过GitBash打开Jupyter笔记本采用jupyter notebook
然后%%bash
魔法应该工作
If one wishes to always be able to run bash within a Jupyter Notebook opened via Anaconda Prompt (similarly using jupyter notebook
):如果希望始终能够在通过 Anaconda Prompt 打开的 Jupyter Notebook 中运行 bash(类似使用jupyter notebook
):
Edit the Jupyter Notebook config file:编辑 Jupyter Notebook 配置文件:
jupyter --config-dir
可以使用jupyter --config-dir
通过 Anaconda Prompt 找到位置c.NotebookApp.terminado_settings = {}
pointed instead to your bash executible (eg): c.NotebookApp.terminado_settings = { 'shell_command': ['C:\\Program Files\\Git\\bin\\bash.exe'] }
使用以下代码行修改并保存: c.NotebookApp.terminado_settings = {}
指向您的 bash 可执行文件(例如): c.NotebookApp.terminado_settings = { 'shell_command': ['C:\\Program Files\\Git\\bin\\bash.exe'] }
Edit your system environment variables:编辑系统环境变量:
Set an environment variable in Jupyter Notebook 在 Jupyter Notebook 中设置环境变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.