ipython-cells


Nameipython-cells JSON
Version 5.2.0 PyPI version JSON
download
home_pagehttps://github.com/uiuc-sine/ipython-cells
SummaryJupyter-like cell running in ipython
upload_time2024-05-02 20:49:44
maintainerNone
docs_urlNone
authorEvan Widloski, Ulaş Kamacι
requires_pythonNone
licenseGPLv3
keywords jupyter ipython cells magic extension
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

![](notebook.png)

Running exported notebook with ipython-cells:

![](commandline.png)


## 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": "https://github.com/uiuc-sine/ipython-cells",
    "name": "ipython-cells",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "jupyter ipython cells magic extension",
    "author": "Evan Widloski, Ula\u015f Kamac\u03b9",
    "author_email": "evan@evanw.org, ukamaci2@illinois.edu",
    "download_url": "https://files.pythonhosted.org/packages/1e/71/d46741dd38ec1abd43c2dd869287dc5532d7410ef19f815066ed143fcc79/ipython_cells-5.2.0.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![](notebook.png)\n\nRunning exported notebook with ipython-cells:\n\n![](commandline.png)\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": "GPLv3",
    "summary": "Jupyter-like cell running in ipython",
    "version": "5.2.0",
    "project_urls": {
        "Homepage": "https://github.com/uiuc-sine/ipython-cells"
    },
    "split_keywords": [
        "jupyter",
        "ipython",
        "cells",
        "magic",
        "extension"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1e71d46741dd38ec1abd43c2dd869287dc5532d7410ef19f815066ed143fcc79",
                "md5": "af8a332d7d949fa8bc7c42158dc2a22b",
                "sha256": "c2008c411c8fbffae2cd6baed3994b778e54ec8a0968e9fae59bf1ceba84d896"
            },
            "downloads": -1,
            "filename": "ipython_cells-5.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "af8a332d7d949fa8bc7c42158dc2a22b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5530,
            "upload_time": "2024-05-02T20:49:44",
            "upload_time_iso_8601": "2024-05-02T20:49:44.096091Z",
            "url": "https://files.pythonhosted.org/packages/1e/71/d46741dd38ec1abd43c2dd869287dc5532d7410ef19f815066ed143fcc79/ipython_cells-5.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-02 20:49:44",
    "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"
}
        
Elapsed time: 0.23948s