Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save fomightez/5684bedfe9c55c52bc8b072e1d6d7a53 to your computer and use it in GitHub Desktop.

Select an option

Save fomightez/5684bedfe9c55c52bc8b072e1d6d7a53 to your computer and use it in GitHub Desktop.
tqdm Progress Bars in jupyterlite or MyBinder Served Jupyter (April_2026)
{
"cells": [
{
"cell_type": "markdown",
"id": "3b2bafbb-5f66-4f25-9e1f-a5524e7f0eae",
"metadata": {},
"source": [
"# Tqdm progress bars in JupyterLite or MyBinder-served Jupyter\n",
"\n",
"\n",
"## JupyterLite trial\n",
"\n",
"This worked April 2026 in JupyterLite launched from the '`try lite now`' badge either at\n",
"- [here](https://jupyterlite.readthedocs.io/en/stable/)\n",
"- [here](https://github.com/jupyterlite/jupyterlite?tab=readme-ov-file#jupyterlite)\n",
"\n",
"-----\n",
"\n",
"## MyBinder-served trial\n",
"\n",
"This worked April 2026 in JupyterLab launched from '`launch binder`' badge [here](https://github.com/jupyterlab/jupyterlab#jupyterlab). **You can though skip the ipywidgets installation as it is already installed in sessions from there.** To do that easily with this notebook, make the first cell 'Raw' and then convert the second cell from 'Raw' to 'Code' and run the notebook. **Fortunately, if `ipywidgets` is already installed running the first cell as it is won't cause a problem at this time.**"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "e0070401-90da-476a-ad2e-afdd869c133d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"# next line based on 'ipywidgets Interactive Demo' notebook in JupyterLite demo, launched from https://jupyterlite.readthedocs.io/, pyodide directory\n",
"%pip install -q tqdm ipywidgets"
]
},
{
"cell_type": "raw",
"id": "8634533b-3456-4c92-9fd2-27a8bad4c81f",
"metadata": {},
"source": [
"%pip install -q tqdm"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "74f7ba5d-1291-40d2-b797-e86d19b2cce8",
"metadata": {},
"outputs": [],
"source": [
"from tqdm.auto import tqdm # based on https://stackoverflow.com/a/58625996/8508004\n",
"#from tqdm import tqdm #based on https://stackoverflow.com/a/75293907/8508004\n",
"import time"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "650d1913-7264-4cad-9a9a-7829f60d1f55",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ecffd900bd75491e89a03ce1b57a31fe",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Loading: 0%| | 0/10 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from tqdm.notebook import tqdm, trange\n",
"import time\n",
"\n",
"for i in trange(10, desc='Loading'):\n",
" time.sleep(0.1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7ab01a86-5727-4767-9fdc-54192534447a",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7467347cdeac4cfcb5530d89d929a4a4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/10000 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"for i in tqdm(range(10000)):\n",
" time.sleep(0.1)"
]
},
{
"cell_type": "raw",
"id": "177a2693-a0d1-474a-8ebe-75355b51b204",
"metadata": {},
"source": [
"for i in tqdm(list(range(0, 1000))):\n",
" time.sleep(1)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "834131bd-f667-4b97-8e2b-9e4f7d0b6209",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.12"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {
"0716b3e1e2ed4ef5a9f3b5d30f427479": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "ProgressStyleModel",
"state": {
"description_width": ""
}
},
"089139a5c73e45ba922e611888bacd1c": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"layout": "IPY_MODEL_12011ad4db8a42838a4a1c3e44912cca",
"style": "IPY_MODEL_87afc103ef174cd8a13ae891561714cb",
"value": " 10/10 [00:01&lt;00:00,  9.42it/s]"
}
},
"0ad3f5c27eee42f2a67d4cf1c0a9e3cd": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HBoxModel",
"state": {
"children": [
"IPY_MODEL_707a6bd08c06486c8c2fb9d45e804805",
"IPY_MODEL_b16b06232b204612a524d4be3a076e82",
"IPY_MODEL_f6441e57c8b4447a830e7bf58e8b8aed"
],
"layout": "IPY_MODEL_1641b9a52251404d96f2aa87c9db2a71"
}
},
"0ae60974089b4e41ad7b70f231d31cd1": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "FloatProgressModel",
"state": {
"bar_style": "success",
"layout": "IPY_MODEL_b2c1b896ebb24a65858d0640499e8b3e",
"max": 10,
"style": "IPY_MODEL_efd914d9ea4b4c9cbd836600c7230d01",
"value": 10
}
},
"11de2ab0792f47698416bbce15df8f17": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"12011ad4db8a42838a4a1c3e44912cca": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"1641b9a52251404d96f2aa87c9db2a71": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"2d0012a77cf64ef790db363694dc5762": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"description_width": ""
}
},
"381438f53f32402882f8e44180068e95": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"layout": "IPY_MODEL_4b917919b4ab4b2f995af998aab97cd7",
"style": "IPY_MODEL_fe83023fcbd649609cb747271f9376c7",
"value": "Loading: 100%"
}
},
"4173d36ed09949a4a98c1176ad717136": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"4b917919b4ab4b2f995af998aab97cd7": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"707a6bd08c06486c8c2fb9d45e804805": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"layout": "IPY_MODEL_4173d36ed09949a4a98c1176ad717136",
"style": "IPY_MODEL_a59e3b19b50b414eae4f3c41a8d4b18e",
"value": " 35%"
}
},
"87afc103ef174cd8a13ae891561714cb": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"description_width": ""
}
},
"a59e3b19b50b414eae4f3c41a8d4b18e": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"description_width": ""
}
},
"b16b06232b204612a524d4be3a076e82": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "FloatProgressModel",
"state": {
"layout": "IPY_MODEL_fad8b53293ad4fad8f47bfb3600f5ad6",
"max": 10000,
"style": "IPY_MODEL_0716b3e1e2ed4ef5a9f3b5d30f427479",
"value": 3532
}
},
"b2c1b896ebb24a65858d0640499e8b3e": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"c4ae6b93e99248368e3776cb3e89490f": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HBoxModel",
"state": {
"children": [
"IPY_MODEL_381438f53f32402882f8e44180068e95",
"IPY_MODEL_0ae60974089b4e41ad7b70f231d31cd1",
"IPY_MODEL_089139a5c73e45ba922e611888bacd1c"
],
"layout": "IPY_MODEL_c580397b1f834813bcaa430bd65e337a"
}
},
"c580397b1f834813bcaa430bd65e337a": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"efd914d9ea4b4c9cbd836600c7230d01": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "ProgressStyleModel",
"state": {
"description_width": ""
}
},
"f6441e57c8b4447a830e7bf58e8b8aed": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLModel",
"state": {
"layout": "IPY_MODEL_11de2ab0792f47698416bbce15df8f17",
"style": "IPY_MODEL_2d0012a77cf64ef790db363694dc5762",
"value": " 3532/10000 [06:15&lt;11:36,  9.29it/s]"
}
},
"fad8b53293ad4fad8f47bfb3600f5ad6": {
"model_module": "@jupyter-widgets/base",
"model_module_version": "2.0.0",
"model_name": "LayoutModel",
"state": {}
},
"fe83023fcbd649609cb747271f9376c7": {
"model_module": "@jupyter-widgets/controls",
"model_module_version": "2.0.0",
"model_name": "HTMLStyleModel",
"state": {
"description_width": ""
}
}
},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment