ipython-notebook

Pipe Ipython magic output to a variable?

跟風遠走 提交于 2019-12-01 02:43:53
I want to run a bash script in my ipython Notebook and save the output as a string in a python variable for further manipulation. Basically I want to pipe the output of the bash magic to a variable, For example the output of something like this: %%bash some_command [options] foo bar What about using this: myvar = !some_command --option1 --option2 foo bar instead of the %%bash magic? Using the ! symbol runs the following command as a shell command, and the results are all stored in myvar . For running multiple commands and collecting the output of all of them, just put together a quick shell

Writing an IPython notebook to HTML or PDF with Table Of Content

橙三吉。 提交于 2019-12-01 01:16:07
问题 Im trying to create a report from my IPython notebook. Im using the toc extension to create a toc for my nb. I already converted the notebook to html, but the toc is not shown and is not linking to the rest of the doc. Is there any way to convert to one of the specified fromat and still keep a link-able (or even non-link-able) TOC? 回答1: Assuming you use IPython 1.x you have the following options to include the toc in the pdf use the latex_book template ( ipython nbconvert --to=latex -

Ipython is working in command prompt but not in browser

时间秒杀一切 提交于 2019-12-01 00:36:14
问题 I am using a windows 8 64 bit laptop. I already have python 2.7 on my pc. So I installed Ipython using the easy_install. I can now see an ipython application file in C:\Python27\Scripts. When I run that file it opens up my cmd and I can write code. However when I say Ipython notebook in the cmd under the same folder it does not open up the notebook in a browser and gives the following error - C:\Users\UserName>cd C:\Python27\Scripts\ C:\Python27\Scripts>Ipython notebook Traceback (most recent

Synchronizing code between jupyter/iPython notebook script and class methods

Deadly 提交于 2019-11-30 22:29:17
I'm trying to figure out the best way to keep code in an Jupyter/iPython notebook and the same code inside of a class method in sync. Here's the use case: I wrote a long script that uses pandas inside a notebook, and have multiple cells which made the development easy, because I could check intermediate results within the notebook. This is very useful with pandas scripts. I downloaded that working code into a Python ".py" file, and converted that script to be a method within a Python class in my program, that is instantiated with the input data, and provides the output as a result of that

IPython Notebook keyboard shortcut search for text

一笑奈何 提交于 2019-11-30 22:09:56
问题 Is there a keyboard shortcut to search for text in an IPython Notebook? I looked under Help | Keyboard shortcuts and there are lots of cool shortcuts but none for searching for text? The notebook is running in FireFox on Ubuntu. 回答1: There is a find-and-replace command in Jupyter. It's key binding is F (command mode): Of course you can find text with the browser's functionality, (I find it sometimes better), but the command in Jupyter is also very useful. I use a lot that function Replace in

ipython notebook toolbar customize

假装没事ソ 提交于 2019-11-30 20:30:13
问题 I want to add a new toolbar button on ipython notebook. I got a good link mentioned this. So I create a new file: ~/.ipython/profile_default/static/custom/custom.js with below content $([IPython.events]).on('notebook_loaded.Notebook', function(){ IPython.toolbar.add_buttons_group([ { 'label' : 'run qtconsole', 'icon' : 'ui-icon-calculator', // select your icon from http://jqueryui.com/themeroller/ 'callback': function(){IPython.notebook.kernel.execute('%qtconsole')} } // add more button here

How to manage and communicate with multiple IPython/Jupyter kernels from a Python script?

十年热恋 提交于 2019-11-30 20:28:57
I want to mimic the functionality of a notebook server, and instead coordinate the creation/management of different IPython/Jupyter kernels from a central body of logic (i.e. my own Python script). For example, I want to: Define an abstract command e.g. "add(x, y)" Communicate the abstract command to multiple kernels e.g. an IPython kernel and Scala kernel Have each kernel execute the command however they wish Return the result from each kernel to the central body of logic Can anyone point me in the direction of how to programmatically start/stop/communicate with multiple IPython/Jupyter

How to recover deleted iPython Notebooks

梦想的初衷 提交于 2019-11-30 19:30:47
I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can't seem to find it in trash (I don't think iPy Notebooks go to the trash). Does anyone know how I can recover the notebook? I am using Mac OS X. Thanks! This is bit of additional info on the answer by Thuener, I did the following to recover my deleted .ipynb file. The cache is in ~/.cache/chromium/Default/Cache/ (I use chromium) used grep in binary search mode, grep -a 'import math' (replace search string by a keyword specific in your code) Edit the binary file in vim (it doesn't open in gedit) The

AttributeError when running unittest sample in iPy Notebook

风流意气都作罢 提交于 2019-11-30 18:51:40
问题 I am new to iPython and trying to help another developer get started and we are both hitting same issues. We are attempting to run a python unittest sample in iPython from https://docs.python.org/2/library/unittest.html#basic-example The code runs just fine from command line on windows and ubuntu without ANY modifications Exact same code from iPy notebook generates following exception: AttributeError: 'module' object has no attribute '/home/myuser/' The filename is: /home/myuser/example

How to add keyboard shortcuts permanently to Jupyter (ipython) notebook?

我的梦境 提交于 2019-11-30 18:45:12
I have the following configuration for shortcuts, that works after running it in the cell of Jupiter notebook: %%javascript IPython.keyboard_manager.command_shortcuts.add_shortcut('ctrl-q', { help: 'Clear all output', // This text will show up on the help page (CTRL-M h or ESC h) handler: function (event) { // Function that gets invoked if (IPython.notebook.mode == 'command') { IPython.notebook.clear_all_output(); return false; } return true; } }); How can I setup Jupiter notebook to make this initialization automatically on startup? I tried adding the same code (without %%javascript ) to C: