IPython Notebook %% bash Magic Error [英] IPython Notebook %%bash Magic Error

查看:167
本文介绍了IPython Notebook %% bash Magic Error的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在试图通过Fernando Perez在IPython笔记本中遵循版本控制教程,其静态版本可以找到这里

I'm trying to follow a version control tutorial in an IPython Notebook by Fernando Perez, a static version of which can be found here.

他广泛使用 %% bash 魔法,但当我使用它我收到以下错误:

He uses the %%bash magic extensively, but When I use it I get the following error:

错误:单元魔术函数 %% bash 未找到。

ERROR: Cell magic function %%bash not found.

即使我使用!git 命令;一切正常。

Even though when I use the !git command; everything works fine.

具体信息:

C:\Python27\Scripts;
C:\Program Files (x86)\Git\cmd;
C:\Program Files (x86)\Git\bin\;

全部都添加到我的系统路径中。

Are all added to my system path.

我正在运行通过Christoph Gohlke的64位Windows二进制文件安装的0.13.2版本的IPython 网站

I'm running the 0.13.2 version of IPython installed via a 64 bit windows binary from Christoph Gohlke at his site.

运行Git 1.8.0

Running Git 1.8.0

相关:

魔术函数`bash` not found

他的解决方案是更新他的IPython版本。我的版本已更新。

His solution is to update his IPython version. My Version is updated.

推荐答案

无效的原因是您在Windows上运行。 Windows确实
没有bash而是cmd。与此一致的是,ipython没有 %% bash
magic,但 %% cmd magic 。您可以尝试将其命令重写为 %% cmd ,但是
要注意cmd与bash不同,因此他的命令可能无法正常运行

The reason that is not working is that you are running on windows. Windows does not have bash but cmd. In line with that is that ipython does not have %%bash magic, but %%cmd magic. You could try rewriting his commands to %%cmd, but beware that cmd is different from bash and so his commands might not work quite right.

要在Windows上运行此笔记本,您需要安装cygwin并从那里运行ipython
。你不需要在cygwin中安装ipython - 运行windows
ipython就好了,但你必须从cygwin shell运行它。

To run this notebook on windows, you need to install cygwin and run ipython from there. You do not need to install ipython in cygwin – running the windows ipython is just fine, but you have to run it from a cygwin shell.

更新:经过一番研究,我发现是什么让cygwin shell
特别:它将bash放入其PATH中。所以你毕竟不需要cygwin。安装
git就足够了。只需创建名为 notebook.bat 的批处理文件或以下内容为
的内容:

Update: After some research, I found out what makes the cygwin shell special: It puts bash in its PATH. So you don’t need cygwin after all. Having git installed is enough. Just create a batch file named notebook.bat or something with the following content:

@echo off
set PATH=%PATH%;C:\Program Files\Git\bin
ipython notebook

使用此批处理文件运行笔记本时, %% bash 命令将可用,工作。

When you run your notebook using this batch file, the %%bash command will be available and working.

这篇关于IPython Notebook %% bash Magic Error的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆