ipython-notebook

Is there a way to run multiple cells simultaneously in IPython notebook?

梦想与她 提交于 2019-11-27 01:18:38
问题 One cell in my notebook executes for a long time, while the other CPU's in the machine are idle. Is it possible to run other cells in parallel? 回答1: Not magically, and probably not what you think but yes. Here is the documentation for ipyparallel (formerly IPython parallel ) that will show you how to spawn multiple IPython kernel. After you are free to distribute the work across cores, and you can prefix cells with %%px0 %%px1 ... %%px999 (once set up) to execute a cell on a specific engine,

How can I check if code is executed in the IPython notebook?

旧城冷巷雨未停 提交于 2019-11-27 01:00:07
I have some Python code example I'd like to share that should do something different if executed in the terminal Python / IPython or in the IPython notebook. How can I check from my Python code if it's running in the IPython notebook? The question is what do you want execute differently. We do our best in IPython prevent the kernel from knowing to which kind of frontend is connected, and actually you can even have a kernel connected to many differents frontends at the same time. Even if you can take a peek at the type of stderr/out to know wether you are in a ZMQ kernel or not, it does not

Spark context 'sc' not defined

纵然是瞬间 提交于 2019-11-27 00:56:46
问题 I am new to Spark and I am trying to install the PySpark by referring to the below site. http://ramhiser.com/2015/02/01/configuring-ipython-notebook-support-for-pyspark/ I tried to install both prebuilt package and also by building the Spark package thru SBT. When I try to run a python code in IPython Notebook I get the below error. NameError Traceback (most recent call last) <ipython-input-1-f7aa330f6984> in <module>() 1 # Check that Spark is working ----> 2 largeRange = sc.parallelize

prevent plot from showing in jupyter notebook

允我心安 提交于 2019-11-27 00:51:06
问题 How can I prevent a specific plot to be shown in Jupyter notebook? I have several plots in a notebook but I want a subset of them to be saved to a file and not shown on the notebook as this slows considerably. A minimal working example for a Jupyter notebook is: %matplotlib inline from numpy.random import randn from matplotlib.pyplot import plot, figure a=randn(3) b=randn(3) for i in range(10): fig=figure() plot(b) fname='s%03d.png'%i fig.savefig(fname) if(i%5==0): figure() plot(a) As you can

How do you suppress output in IPython Notebook?

独自空忆成欢 提交于 2019-11-27 00:43:42
How can output to stdout be suppressed? A semi-colon can be used to supress display of returned objects, for example >>> 1+1 2 >>> 1+1; # No output! However, a function that prints to stdout is not affected by the semi-colon. >>> print('Hello!') Hello! >>> MyFunction() Calculating values... How can the output from print / MyFunction be suppressed? Add %%capture as the first line of the cell. eg %%capture print('Hello') MyFunction() This simply discards the output, but the %%capture magic can be used to save the output to a variable - consult the docs Suppress output Put a ; at the end of a

Suppress code in NBConvert? IPython

心不动则不痛 提交于 2019-11-27 00:38:24
问题 I have figured out how to suppress large code blocks from showing up in final NB convert (PDF) output. By putting the LaTex command in a "raw cell before the code I don't want to have in the final output \iffalse Followed By this at the end In a raw cell \fi But That still leaves me with some ugly code when I need to show figures and the like and while the base purpose of the notebook is to show code with results, sometimes for a non tech audience we only need the output.. Any Ideas? Somewhat

How do I delete/refresh available kernels for IPython/Jupyter notebook v4.0?

大兔子大兔子 提交于 2019-11-27 00:27:22
问题 I've recently stopped using macports so the kernel.json files I had for various IPython kernels are out of date. I have renamed ~/.ipython and removed ~/.jupyter but kernels launched are failing to start with file not found errors. More tellingly, when I run jupyter-kernelspec list it still lists all the old kernels I had set up. Where is it getting this information from and what do I need to do to refresh/remove its cache? 回答1: After a brute force search, Jupyter stores kernel info for OS X

Adding custom styled paragraphs in markdown cells

我与影子孤独终老i 提交于 2019-11-27 00:17:58
问题 I want to add more formatting elements than provided by the Markdown synthax in an IPython Notebook. For example, I want to add a "Warning Box" or a "Memo Box" that are basically paragraph with different styles (for example different background color, border, an icon, etc...). I guess I can add HTML code in the cell, for example a <div> with an inline style. But what is the "proper" way to do that, I mean the one that ipython developer promote? Examples appreciated. NB: I'm using the current

How to close IPython Notebook properly?

和自甴很熟 提交于 2019-11-26 23:57:18
问题 How to close IPython Notebook properly? Currently, I just close the browser tabs and then use Ctrl+C in the terminal. Unfortunately, neither exit() nor ticking Kill kernel upon exit does help (they do kill the kernel they but don't exit the iPython). 回答1: There isn't currently a better way to do it than Ctrl+C in the terminal. We're thinking about how to have an explicit shutdown, but there's some tension between the notebook as a single-user application, where the user is free to stop it,

Matplotlib and Ipython-notebook: Displaying exactly the figure that will be saved

纵饮孤独 提交于 2019-11-26 21:04:01
I am using ipython-notebook a lot at the moment for numerical analysis and plotting of data. In the process of preparing publication quality plots there is a lot of tweaking to get the layout just right, however I can't get ipython/matplotlib to show me what I will be saving in the browser. Making the process more painful than it should be because I have to keep opening the new output file to check it. Is there a way to get the image that is displayed inline to be the same as the image that is saved? Example as follows, facecolor='gray' for clarity: import matplotlib.pyplot as plt import numpy