# ipython-cells
This is an IPython extension for those who prefer to work in a terminal but still need the cell-by-cell execution provided by a Jupyter notebook.
Example Jupyter notebook:

Running exported notebook with ipython-cells:

## Quickstart
Install the extension:
pip install ipython-cells
Convert an existing notebook to a Python file (In Jupyter):
Cell > Run All
File > Download As > python (.py)
Execute cells in iPython:
``` python
>>> %load_ext ipython_cells
>>> %load_file my_notebook.py
>>> %cell_run 1
>>> %cell_run 2
array([1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j])
```
You can freely add/delete/rename cells in the downloaded `my_notebook.py`. `my_notebook.py` is automatically reloaded when changes are made.
Alternatively, you can create a new .py file from scratch without starting from a Jupyter notebook. See the [cell delimiter syntax](#cell-delimiter-syntax).
## Other Features
Spyder cell delimiter syntax is also supported:
``` python
# %% cell1
print('hello')
# %% cell2
print('world')
```
Other commands:
``` python
# cell ranges - run all cells from beginning of file to cell2 (inclusive)
>>> %cell_run ^cell2
hello
world
# cell ranges - run all cells from cell1 (inclusive) to end of file
>>> %cell_run cell1$
hello
world
# list available cells for running
>>> %list_cells
['__first', 'cell1', 'cell2']
```
## Automatically Load Extension
To load extension on IPython start, add this to `~/.ipython/profile_default/ipython_config.py`
``` python
c.InteractiveShellApp.extensions = [
'ipython_cells'
]
```
## Autoreloading
``` python
# load example.py with autoreloading
%load_file example.py
%cell_run cell1
10
# example.py is modified by an external editor (e.g. `a = 10` -> `a = 20`)
# File change is detected and automatically reloaded
%cell_run cell1
20
```
Auto reloading can be disabled with `%load_file example.py --noreload`
## Cell Delimiter Syntax
Cells are delimited by special comments. Both Jupyter and Spyder style cells are supported. Below are different variations of a cell called `foobar_cell`.
- `# %% foobar_cell`
- `# In[foobar_cell]`
- `# %% foobar_cell some extra text`
- `# In[foobar_cell] some extra text`
## Running Exported Jupyter Notebooks
This extension can run exported Jupyter notebooks. (`File > Download As > python (.py)`).
Be sure to run all cells before exporting so they are assigned an index. (`Cell > Run All`).
## Tests
cd tests
ipython3 tests.py
Raw data
{
"_id": null,
"home_page": null,
"name": "ipython-cells",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "jupyter, ipython, cells, magic, extension",
"author": null,
"author_email": "Evan Widloski <evan_gh@widloski.com>, Ula\u015f Kamac\u03b9 <ukamaci2@illinois.edu>",
"download_url": "https://files.pythonhosted.org/packages/86/64/d747a23056f779195f901c63b8a108a354af77dca1187fb8a7cd91625795/ipython_cells-5.2.2.tar.gz",
"platform": null,
"description": "# ipython-cells\n\nThis is an IPython extension for those who prefer to work in a terminal but still need the cell-by-cell execution provided by a Jupyter notebook.\n\nExample Jupyter notebook:\n\n\n\nRunning exported notebook with ipython-cells:\n\n\n\n\n## Quickstart\n\nInstall the extension:\n\n pip install ipython-cells\n \nConvert an existing notebook to a Python file (In Jupyter):\n\n Cell > Run All\n File > Download As > python (.py)\n\nExecute cells in iPython:\n\n``` python\n>>> %load_ext ipython_cells\n>>> %load_file my_notebook.py\n>>> %cell_run 1\n>>> %cell_run 2\narray([1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j, 1.+0.j])\n```\n\nYou can freely add/delete/rename cells in the downloaded `my_notebook.py`. `my_notebook.py` is automatically reloaded when changes are made.\n \nAlternatively, you can create a new .py file from scratch without starting from a Jupyter notebook. See the [cell delimiter syntax](#cell-delimiter-syntax).\n\n## Other Features\n\nSpyder cell delimiter syntax is also supported:\n\n``` python\n# %% cell1\nprint('hello')\n\n# %% cell2\nprint('world')\n```\n\nOther commands:\n\n``` python\n# cell ranges - run all cells from beginning of file to cell2 (inclusive)\n>>> %cell_run ^cell2\nhello\nworld\n\n# cell ranges - run all cells from cell1 (inclusive) to end of file\n>>> %cell_run cell1$\nhello\nworld\n\n# list available cells for running\n>>> %list_cells\n['__first', 'cell1', 'cell2']\n```\n\n\n## Automatically Load Extension\n\nTo load extension on IPython start, add this to `~/.ipython/profile_default/ipython_config.py`\n\n``` python\nc.InteractiveShellApp.extensions = [\n 'ipython_cells'\n]\n```\n\n## Autoreloading\n``` python\n# load example.py with autoreloading\n%load_file example.py\n\n%cell_run cell1\n10\n# example.py is modified by an external editor (e.g. `a = 10` -> `a = 20`)\n# File change is detected and automatically reloaded\n%cell_run cell1\n20\n\n```\n\nAuto reloading can be disabled with `%load_file example.py --noreload`\n\n## Cell Delimiter Syntax\n\nCells are delimited by special comments. Both Jupyter and Spyder style cells are supported. Below are different variations of a cell called `foobar_cell`.\n\n- `# %% foobar_cell`\n- `# In[foobar_cell]`\n- `# %% foobar_cell some extra text`\n- `# In[foobar_cell] some extra text`\n\n## Running Exported Jupyter Notebooks\n\nThis extension can run exported Jupyter notebooks. (`File > Download As > python (.py)`).\n\nBe sure to run all cells before exporting so they are assigned an index. (`Cell > Run All`).\n\n## Tests\n\n cd tests\n ipython3 tests.py\n",
"bugtrack_url": null,
"license": "GPL-3.0",
"summary": "Jupyter-like cell running in ipython",
"version": "5.2.2",
"project_urls": {
"Homepage": "https://github.com/uiuc-sine/ipython-cells",
"Issues": "https://github.com/uiuc-sine/ipython-cells/issues",
"Repository": "https://github.com/uiuc-sine/ipython-cells"
},
"split_keywords": [
"jupyter",
" ipython",
" cells",
" magic",
" extension"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a2a07ee7894e53aa4222762cfa5181ea758e085b5f47d1293247dff3683d371f",
"md5": "af565f51609448ec53ca31d90edc29f0",
"sha256": "2f5fe6eafe4f4190807d11da06b7a44c16742664c4fc8352b9fbf609a2ba0453"
},
"downloads": -1,
"filename": "ipython_cells-5.2.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "af565f51609448ec53ca31d90edc29f0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 5670,
"upload_time": "2025-10-28T18:38:21",
"upload_time_iso_8601": "2025-10-28T18:38:21.512584Z",
"url": "https://files.pythonhosted.org/packages/a2/a0/7ee7894e53aa4222762cfa5181ea758e085b5f47d1293247dff3683d371f/ipython_cells-5.2.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "8664d747a23056f779195f901c63b8a108a354af77dca1187fb8a7cd91625795",
"md5": "995b4536d474dbfe338ad039bd999f82",
"sha256": "c430d3177a594cef730e88366435e3be4f800c31ca2f173fe6234d4c6b23cf46"
},
"downloads": -1,
"filename": "ipython_cells-5.2.2.tar.gz",
"has_sig": false,
"md5_digest": "995b4536d474dbfe338ad039bd999f82",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 45912,
"upload_time": "2025-10-28T18:38:22",
"upload_time_iso_8601": "2025-10-28T18:38:22.322806Z",
"url": "https://files.pythonhosted.org/packages/86/64/d747a23056f779195f901c63b8a108a354af77dca1187fb8a7cd91625795/ipython_cells-5.2.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-28 18:38:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "uiuc-sine",
"github_project": "ipython-cells",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ipython-cells"
}