2016-05-19 101 views
0

我正在使用Windows 7和Python 3.4的PC 3.4來自Anaconda3 2.3.0的Jupyter筆記本。Jupyter筆記本 - 找不到程序:'bash'

我試圖從Jupyter筆記本上運行單元魔術bash命令,並遇到我想其他人也會遇到的問題。

從我的教程中所看到的,它應該是那樣簡單......

%%bash 
pwd 

當我嘗試,我得到錯誤「無法找到程序:‘慶典’」。其他bash命令也是如此。我也試過!bash並沒有奏效。

一些奇怪的觀察,可以幫助:

我能夠運行不需要參數,只要它們在細胞中的第一行的bash命令。

In: 
ls  

Out: 
Volume in drive D is DATA 
Volume Serial Number is XXXX-XXXX 

Directory of D:\... 

05/19/2016 06:25 PM <DIR>   . 

但是,如果我把上面的命令返回,這似乎解釋了細胞的蟒蛇,並給出了「名‘LS’沒有定義」的錯誤。

如果我嘗試調用bash系魔法命令%bash我得到下面的錯誤:

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

預先感謝任何幫助。

+2

不要細胞魔法依賴底層操作系統嗎?如果你在Windows上,那麼你可能沒有bash。請參閱[這可能相關的問題和答案](http://stackoverflow.com/questions/16281910/ipython-notebook-bash-magic-error) – buruzaemon

回答

1

你嘗試了什麼錯誤消息說試試?

即代替「%慶典」

This page「%%慶典」似乎表明,你會想要兩個百分號利用的bash腳本魔力。

編輯。定製的答案不再是特定的errawr消息。當我跑%lsmagic我得到如下:

%lsmagic 

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. 

以下命令作品:

%%cmd 
dir 

buruzaemon釘它。

+1

嗨,謝謝你的幫助。我確實嘗試了%% bash - 這實際上是我首先嚐試的,這就是它看起來應該在我見過的教程中工作的原因。如果我沒有在上面說得很清楚,請道歉。 當我嘗試我得到錯誤「找不到程序:'bash'」 –