This page was generated from
doc/gallery/multiple-outputs.ipynb.
Interactive online version:
.
Download notebook.
Choosing from Multiple Outputs¶
By default, the last output of the selected cell is used as a thumbnail. If that’s what you want, you can simply use the nbsphinx-thumbnail cell tag.
If you want to specify one of multiple outputs, you can add a (zero-based) "output-index"
to your "nbsphinx-thumbnail"
cell metadata.
The following cell has this metadata, selecting the third output to be used as thumbnail in the gallery.
{
"nbsphinx-thumbnail": {
"output-index": 2
}
}
[1]:
from IPython.display import Image
display(Image(url='https://jupyter.org/assets/homepage/main-logo.svg'))
print('Hello!')
display(Image(filename='../images/notebook_icon.png'))
display(Image(url='https://www.python.org/static/img/python-logo-large.png', embed=True))
Hello!

---------------------------------------------------------------------------
gaierror Traceback (most recent call last)
File /usr/lib64/python3.14/urllib/request.py:1321, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1320 try:
-> 1321 h.request(req.get_method(), req.selector, req.data, headers,
1322 encode_chunked=req.has_header('Transfer-encoding'))
1323 except OSError as err: # timeout error
File /usr/lib64/python3.14/http/client.py:1338, in HTTPConnection.request(self, method, url, body, headers, encode_chunked)
1337 """Send a complete request to the server."""
-> 1338 self._send_request(method, url, body, headers, encode_chunked)
File /usr/lib64/python3.14/http/client.py:1384, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked)
1383 body = _encode(body, 'body')
-> 1384 self.endheaders(body, encode_chunked=encode_chunked)
File /usr/lib64/python3.14/http/client.py:1333, in HTTPConnection.endheaders(self, message_body, encode_chunked)
1332 raise CannotSendHeader()
-> 1333 self._send_output(message_body, encode_chunked=encode_chunked)
File /usr/lib64/python3.14/http/client.py:1093, in HTTPConnection._send_output(self, message_body, encode_chunked)
1092 del self._buffer[:]
-> 1093 self.send(msg)
1095 if message_body is not None:
1096
1097 # create a consistent interface to message_body
File /usr/lib64/python3.14/http/client.py:1037, in HTTPConnection.send(self, data)
1036 if self.auto_open:
-> 1037 self.connect()
1038 else:
File /usr/lib64/python3.14/http/client.py:1472, in HTTPSConnection.connect(self)
1470 "Connect to a host on a given (SSL) port."
-> 1472 super().connect()
1474 if self._tunnel_host:
File /usr/lib64/python3.14/http/client.py:1003, in HTTPConnection.connect(self)
1002 sys.audit("http.client.connect", self, self.host, self.port)
-> 1003 self.sock = self._create_connection(
1004 (self.host,self.port), self.timeout, self.source_address)
1005 # Might fail in OSs that don't implement TCP_NODELAY
File /usr/lib64/python3.14/socket.py:846, in create_connection(address, timeout, source_address, all_errors)
845 exceptions = []
--> 846 for res in getaddrinfo(host, port, 0, SOCK_STREAM):
847 af, socktype, proto, canonname, sa = res
File /usr/lib64/python3.14/socket.py:983, in getaddrinfo(host, port, family, type, proto, flags)
982 addrlist = []
--> 983 for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
984 af, socktype, proto, canonname, sa = res
gaierror: [Errno -3] Temporary failure in name resolution
During handling of the above exception, another exception occurred:
URLError Traceback (most recent call last)
Cell In[1], line 6
4 print('Hello!')
5 display(Image(filename='../images/notebook_icon.png'))
----> 6 display(Image(url='https://www.python.org/static/img/python-logo-large.png', embed=True))
File /usr/lib/python3.14/site-packages/IPython/core/display.py:1053, in Image.__init__(self, data, url, filename, format, embed, width, height, retina, unconfined, metadata, alt)
1051 self.unconfined = unconfined
1052 self.alt = alt
-> 1053 super(Image, self).__init__(data=data, url=url, filename=filename,
1054 metadata=metadata)
1056 if self.width is None and self.metadata.get('width', {}):
1057 self.width = metadata['width']
File /usr/lib/python3.14/site-packages/IPython/core/display.py:371, in DisplayObject.__init__(self, data, url, filename, metadata)
368 elif self.metadata is None:
369 self.metadata = {}
--> 371 self.reload()
372 self._check_data()
File /usr/lib/python3.14/site-packages/IPython/core/display.py:1088, in Image.reload(self)
1086 """Reload the raw data from file or URL."""
1087 if self.embed:
-> 1088 super(Image,self).reload()
1089 if self.retina:
1090 self._retina_shape()
File /usr/lib/python3.14/site-packages/IPython/core/display.py:402, in DisplayObject.reload(self)
399 elif self.url is not None:
400 # Deferred import
401 from urllib.request import urlopen
--> 402 response = urlopen(self.url)
403 data = response.read()
404 # extract encoding from header, if there is one:
File /usr/lib64/python3.14/urllib/request.py:187, in urlopen(url, data, timeout, context)
185 else:
186 opener = _opener
--> 187 return opener.open(url, data, timeout)
File /usr/lib64/python3.14/urllib/request.py:487, in OpenerDirector.open(self, fullurl, data, timeout)
484 req = meth(req)
486 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method())
--> 487 response = self._open(req, data)
489 # post-process response
490 meth_name = protocol+"_response"
File /usr/lib64/python3.14/urllib/request.py:504, in OpenerDirector._open(self, req, data)
501 return result
503 protocol = req.type
--> 504 result = self._call_chain(self.handle_open, protocol, protocol +
505 '_open', req)
506 if result:
507 return result
File /usr/lib64/python3.14/urllib/request.py:464, in OpenerDirector._call_chain(self, chain, kind, meth_name, *args)
462 for handler in handlers:
463 func = getattr(handler, meth_name)
--> 464 result = func(*args)
465 if result is not None:
466 return result
File /usr/lib64/python3.14/urllib/request.py:1369, in HTTPSHandler.https_open(self, req)
1368 def https_open(self, req):
-> 1369 return self.do_open(http.client.HTTPSConnection, req,
1370 context=self._context)
File /usr/lib64/python3.14/urllib/request.py:1324, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args)
1321 h.request(req.get_method(), req.selector, req.data, headers,
1322 encode_chunked=req.has_header('Transfer-encoding'))
1323 except OSError as err: # timeout error
-> 1324 raise URLError(err)
1325 r = h.getresponse()
1326 except:
URLError: <urlopen error [Errno -3] Temporary failure in name resolution>