Questions tagged [ipython]

IPython is a feature-rich interactive shell for Python, and provides a kernel for frontends such as IPython Notebook and Jupyter Notebook.

IPython provides a rich architecture for interactive computing with . It includes:


Version updates:

The IPython 3.x release series is the last where IPython is released as one big package. Starting with IPython 4.0, the parts which work for any language are called , while the parts specific to executing Python code remain as IPython.

IPython 5.0 is the last major release to support Python 2.x.


Links:

7180 questions
202
votes
16 answers

Step-by-step debugging with IPython

From what I have read, there are two ways to debug code in Python: With a traditional debugger such as pdb or ipdb. This supports commands such as c for continue, n for step-over, s for step-into etc.), but you don't have direct access to an…
Amelio Vazquez-Reina
  • 91,494
  • 132
  • 359
  • 564
199
votes
23 answers

How to hide code from cells in ipython notebook visualized with nbviewer?

I have an ipython/jupyter notebook that I visualize using NBviewer. How can I hide all the code from the notebook rendered by NBviewer, so that only the output of code (e.g. plots and tables) and the markdown cells are shown?
lucacerone
  • 9,859
  • 13
  • 52
  • 80
198
votes
17 answers

My plot in ipython does not show with pyplot.show()

Help required displaying matplotlib plots in ipython. I did not forget to call pyplot.show(). $ ipython --pylab import matplotlib.pyplot as plt plt.plot(range(20), range(20)) It returns matplotlib.lines.Line2D at 0xade2b2c as the…
Baskaya
  • 7,651
  • 6
  • 29
  • 27
197
votes
12 answers

Showing line numbers in IPython/Jupyter Notebooks

Error reports from most language kernels running in IPython/Jupyter Notebooks indicate the line on which the error occurred; but (at least by default) no line numbers are indicated in notebooks. Is it possible to add the line numbers to…
Ruggero Turra
  • 16,929
  • 16
  • 85
  • 141
195
votes
4 answers

How do you suppress output in Jupyter running IPython?

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. >>>…
Zero
  • 11,593
  • 9
  • 52
  • 70
187
votes
8 answers

How to clear variables in ipython?

Sometimes I rerun a script within the same ipython session and I get bad surprises when variables haven't been cleared. How do I clear all variables? And is it possible to force this somehow every time I invoke the magic command %run?
grasshopper
  • 3,988
  • 3
  • 23
  • 29
184
votes
13 answers

IOPub data rate exceeded in Jupyter notebook (when viewing image)

I want to view an image in Jupyter notebook. It's a 9.9MB .png file. from IPython.display import Image Image(filename='path_to_image/image.png') I get the below error: IOPub data rate exceeded. The notebook server will temporarily stop sending…
lmart999
  • 6,671
  • 10
  • 29
  • 37
180
votes
10 answers

How to change color in markdown cells ipython/jupyter notebook?

I'm only looking to format a specific string within a cell. I change that cell's format to "Markdown" but I'm not sure how to change text color of a single word. I don't want to change the look of the whole notebook (via a CSS file).
punkrockpolly
  • 9,270
  • 6
  • 36
  • 37
178
votes
11 answers

Importing an ipynb file from another ipynb file?

Interactive Python (ipython) is simply amazing, especially as you are piecing things together on the fly... and does it in such a way that it is easy to go back. However, what seems to be interesting is the use-case of having multiple ipython…
Andrew Harris
  • 1,975
  • 2
  • 13
  • 8
170
votes
3 answers

ipython: print complete history (not just current session)

in ipython, I can use %hist or %history to print recent history, but this only prints history from current session. I would like to print all history, similar as bash historycommand does. What I am trying to do is to get complete history, so that I…
user1968963
  • 2,371
  • 3
  • 21
  • 22
164
votes
4 answers

How to display full output in Jupyter, not only last result?

I want Jupyter to print all the interactive output without resorting to print, not only the last result. How to do it? Example : a=3 a a+1 I would like to display 3 4
mbh86
  • 6,078
  • 3
  • 18
  • 31
163
votes
8 answers

How to programmatically generate markdown output in Jupyter notebooks?

I want to write a report for classes in Jupyter notebook. I'd like to count some stuff, generate some results and include them in markdown. Can I set the output of the cell to be interpreted as markdown? I'd like such command: print '$\phi$' to…
fulaphex
  • 2,879
  • 3
  • 19
  • 26
160
votes
6 answers

Running python script inside ipython

Is it possible to run a python script (not module) from inside ipython without indicating its path? I tried to set PYTHONPATH but it seems to work only for modules. I would like to execute %run my_script.py without being in the directory…
Tyler Durden
  • 1,611
  • 2
  • 11
  • 3
158
votes
4 answers

Passing IPython variables as arguments to bash commands

How do I execute a bash command from Ipython/Jupyter notebook passing the value of a python variable as an argument like in this example: py_var="foo" !grep py_var bar.txt (obviously I want to grep for foo and not the literal string py_var)
Unni
  • 5,348
  • 6
  • 36
  • 55
152
votes
5 answers

What is %timeit in Python?

I always read the code to calculate the time like this way: %timeit function() What does "%" mean here? I think, the "%" is always used to replace something in a string, like %s means replace a string, %d replace a data, but I have no idea about…
xirururu
  • 5,028
  • 9
  • 35
  • 64