pypowsybl-jupyter


Namepypowsybl-jupyter JSON
Version 1.2.0 PyPI version JSON
download
home_pageNone
SummaryWidgets for pypowsybl in Jupyter notebooks
upload_time2025-09-10 14:46:04
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseNone
keywords ipython jupyter widgets
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI Latest Release](https://img.shields.io/pypi/v/pypowsybl-jupyter.svg)](https://pypi.org/project/pypowsybl-jupyter/)
[![Documentation Status](https://readthedocs.org/projects/pypowsybl-jupyter/badge/?version=latest)](https://powsybl.readthedocs.io/projects/pypowsybl-jupyter/en/latest/?badge=latest)
[![MPL-2.0 License](https://img.shields.io/badge/license-MPL_2.0-blue.svg)](https://www.mozilla.org/en-US/MPL/2.0/)
[![Slack](https://img.shields.io/badge/slack-powsybl-blueviolet.svg?logo=slack)](https://join.slack.com/t/powsybl/shared_invite/zt-36jvd725u-cnquPgZb6kpjH8SKh~FWHQ)
[![Actions Status](https://github.com/powsybl/pypowsybl/workflows/Full%20CI/badge.svg)](https://github.com/powsybl/pypowsybl-jupyter/actions)

# pypowsybl-jupyter

Widgets for [PyPowSyBl](https://github.com/powsybl/pypowsybl) in [Jupyter](https://jupyter.org) notebooks.

Pypowsybl-jupyter integrates the [powsybl-diagram-viewer](https://github.com/powsybl/powsybl-diagram-viewer) library to display diagrams and is built on [anywidget](https://github.com/manzt/anywidget/), an abstraction around the [Jupyter Widget](https://github.com/jupyter-widgets/ipywidgets) framework.

The widgets should work with versions of Jupyter Lab >= 4, Notebook >= 7.

## Installation

You can install the widgets binaries using `pip`:

```bash
pip install pypowsybl_jupyter
```

## Examples

In the examples directory there are some notebooks demonstrating the widgets.


## Development installation

Create a virtual environment and install pypowsybl_jupyter in *editable* mode with the optional development dependencies:

```sh
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
```

For example, in editable mode you can watch the source directory for changes, to automatically rebuild the widget, and run JupyterLab in different terminals. Changes made in `js/` will be reflected in an open notebook where the widget is used.

Please note that pip only supports editable installs (enabled with the option -e) from a pyproject.toml files since v21.3. Make sure you have an up-to-date version of pip
```sh
pip install --upgrade pip
```


```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
npm run dev
# Run JupyterLab in another terminal.
# Please ensure that you also activate the virtual environment in the new terminal.
source .venv/bin/activate
jupyter lab
```

To enable the automatic reloading in Jupyter, please define this environment variable:

```py
%env ANYWIDGET_HMR=1
```
or, before launching a Jupyter session:

```bash
ANYWIDGET_HMR=1 jupyter lab
```

The changes should take effect after saving a source file. In case a change is not recognized, restarting the notebook kernel may help.

## Packaging for distribution

To package pypowsybl_jupyter in a .whl file, for distribution:
```bash
pip install build
python -m build --wheel
```

The 'created .whl file' will be available in the 'dist' directory. To install the .whl file:
```bash
pip install <'created .whl file'>
```

## Notes

Jupyter Widgets require Javascript extension code that Jupyter Lab needs to locate upon kernel startup.

In a standalone Jupyter Lab setup, the widget package is usually deployed in the same environment, allowing Jupyter Lab to find and load the necessary JS code seamlessly (e.g., if you **pip install pypowsybl_jupyter** in your standalone environment, then start Jupyter Lab, the extension is activated and anywidget and Jupyter Widget are listed among the installed dependencies).

However, installing Jupyter Widgets in kernels that are spawned by more controlled environment like [Mybinder](https://mybinder.org/), doesn't apparently let Jupyter Lab find the JS extension code, causing widgets to fail to display properly (e.g., in these cases, if you **pip install pypowsybl_jupyter** from inside a notebook a javascript error could appear in the widget's cell, with a message similar to *"Failed to load view class 'AnyView' from module 'anywidget'"*, despite the fact that no errors are shown during the installation nor that anywidget and Jupyter widget are still listed among the installed dependencies).

To resolve this known limitation, widget packages need to be installed in such a way that they are available to the hosting environment. In the Mybinder case it seems to be sufficient to add an **anywidget** entry to the project's **requirements.txt** file, which is used by Mybinder's infrastructure to instantiate Jupyter Lab. Once anywidget is installed succesfully, any custom widget developed using anywidget, like pypowsybl_jupyter's widgets, can be installed and managed correctly from a notebook (i.e., running **pip install pypowsybl_jupyter** in a notebook should work correctly).

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "pypowsybl-jupyter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "IPython, Jupyter, Widgets",
    "author": null,
    "author_email": "Sylvain Leclerc <sylvain.leclerc@rte-france.com>, Christian Biasuzzi <christian.biasuzzi@soft.it>",
    "download_url": null,
    "platform": null,
    "description": "[![PyPI Latest Release](https://img.shields.io/pypi/v/pypowsybl-jupyter.svg)](https://pypi.org/project/pypowsybl-jupyter/)\n[![Documentation Status](https://readthedocs.org/projects/pypowsybl-jupyter/badge/?version=latest)](https://powsybl.readthedocs.io/projects/pypowsybl-jupyter/en/latest/?badge=latest)\n[![MPL-2.0 License](https://img.shields.io/badge/license-MPL_2.0-blue.svg)](https://www.mozilla.org/en-US/MPL/2.0/)\n[![Slack](https://img.shields.io/badge/slack-powsybl-blueviolet.svg?logo=slack)](https://join.slack.com/t/powsybl/shared_invite/zt-36jvd725u-cnquPgZb6kpjH8SKh~FWHQ)\n[![Actions Status](https://github.com/powsybl/pypowsybl/workflows/Full%20CI/badge.svg)](https://github.com/powsybl/pypowsybl-jupyter/actions)\n\n# pypowsybl-jupyter\n\nWidgets for [PyPowSyBl](https://github.com/powsybl/pypowsybl) in [Jupyter](https://jupyter.org) notebooks.\n\nPypowsybl-jupyter integrates the [powsybl-diagram-viewer](https://github.com/powsybl/powsybl-diagram-viewer) library to display diagrams and is built on [anywidget](https://github.com/manzt/anywidget/), an abstraction around the [Jupyter Widget](https://github.com/jupyter-widgets/ipywidgets) framework.\n\nThe widgets should work with versions of Jupyter Lab >= 4, Notebook >= 7.\n\n## Installation\n\nYou can install the widgets binaries using `pip`:\n\n```bash\npip install pypowsybl_jupyter\n```\n\n## Examples\n\nIn the examples directory there are some notebooks demonstrating the widgets.\n\n\n## Development installation\n\nCreate a virtual environment and install pypowsybl_jupyter in *editable* mode with the optional development dependencies:\n\n```sh\npython -m venv .venv\nsource .venv/bin/activate\npip install -e \".[dev]\"\n```\n\nFor example, in editable mode you can watch the source directory for changes, to automatically rebuild the widget, and run JupyterLab in different terminals. Changes made in `js/` will be reflected in an open notebook where the widget is used.\n\nPlease note that pip only supports editable installs (enabled with the option -e) from a pyproject.toml files since v21.3. Make sure you have an up-to-date version of pip\n```sh\npip install --upgrade pip\n```\n\n\n```bash\n# Watch the source directory in one terminal, automatically rebuilding when needed\nnpm run dev\n# Run JupyterLab in another terminal.\n# Please ensure that you also activate the virtual environment in the new terminal.\nsource .venv/bin/activate\njupyter lab\n```\n\nTo enable the automatic reloading in Jupyter, please define this environment variable:\n\n```py\n%env ANYWIDGET_HMR=1\n```\nor, before launching a Jupyter session:\n\n```bash\nANYWIDGET_HMR=1 jupyter lab\n```\n\nThe changes should take effect after saving a source file. In case a change is not recognized, restarting the notebook kernel may help.\n\n## Packaging for distribution\n\nTo package pypowsybl_jupyter in a .whl file, for distribution:\n```bash\npip install build\npython -m build --wheel\n```\n\nThe 'created .whl file' will be available in the 'dist' directory. To install the .whl file:\n```bash\npip install <'created .whl file'>\n```\n\n## Notes\n\nJupyter Widgets require Javascript extension code that Jupyter Lab needs to locate upon kernel startup.\n\nIn a standalone Jupyter Lab setup, the widget package is usually deployed in the same environment, allowing Jupyter Lab to find and load the necessary JS code seamlessly (e.g., if you **pip install pypowsybl_jupyter** in your standalone environment, then start Jupyter Lab, the extension is activated and anywidget and Jupyter Widget are listed among the installed dependencies).\n\nHowever, installing Jupyter Widgets in kernels that are spawned by more controlled environment like [Mybinder](https://mybinder.org/), doesn't apparently let Jupyter Lab find the JS extension code, causing widgets to fail to display properly (e.g., in these cases, if you **pip install pypowsybl_jupyter** from inside a notebook a javascript error could appear in the widget's cell, with a message similar to *\"Failed to load view class 'AnyView' from module 'anywidget'\"*, despite the fact that no errors are shown during the installation nor that anywidget and Jupyter widget are still listed among the installed dependencies).\n\nTo resolve this known limitation, widget packages need to be installed in such a way that they are available to the hosting environment. In the Mybinder case it seems to be sufficient to add an **anywidget** entry to the project's **requirements.txt** file, which is used by Mybinder's infrastructure to instantiate Jupyter Lab. Once anywidget is installed succesfully, any custom widget developed using anywidget, like pypowsybl_jupyter's widgets, can be installed and managed correctly from a notebook (i.e., running **pip install pypowsybl_jupyter** in a notebook should work correctly).\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Widgets for pypowsybl in Jupyter notebooks",
    "version": "1.2.0",
    "project_urls": {
        "Homepage": "https://github.com/powsybl/pypowsybl-jupyter"
    },
    "split_keywords": [
        "ipython",
        " jupyter",
        " widgets"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "00522dd6b199a00a89b0697c7a51e1b050056680847b41ebca90341e9056d925",
                "md5": "2d6ff8f0d5af10a9d3e413bdd8b382d4",
                "sha256": "9345f9e0c2f4e3fb19e4977862012ed7fec36c4485355524c0f36b9a178be95a"
            },
            "downloads": -1,
            "filename": "pypowsybl_jupyter-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2d6ff8f0d5af10a9d3e413bdd8b382d4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 3152057,
            "upload_time": "2025-09-10T14:46:04",
            "upload_time_iso_8601": "2025-09-10T14:46:04.768617Z",
            "url": "https://files.pythonhosted.org/packages/00/52/2dd6b199a00a89b0697c7a51e1b050056680847b41ebca90341e9056d925/pypowsybl_jupyter-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-10 14:46:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "powsybl",
    "github_project": "pypowsybl-jupyter",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pypowsybl-jupyter"
}
        
Elapsed time: 3.31800s