Installation#

Users can install the current version ofipywidgets withpip orconda.

In most cases, installing the Pythonipywidgets package will also automatically configure classic Jupyter Notebook and JupyterLab 3.x to display ipywidgets. With pip, do:

pipinstallipywidgets

or with conda, do:

condainstall-cconda-forgeipywidgets

Installing in JupyterLab 3.x#

Most of the time, installingipywidgets automatically configures JupyterLab 3.x to use widgets. Theipywidgets package does this by depending on thejupyterlab_widgets package, which configures JupyterLab 3 to display and use widgets.

If JupyterLab and the IPython kernel are installed in differentenvironments (for example, separate environments are providing differentPython kernels), then the installation requires two steps:

  1. Install thejupyterlab_widgets package in the environment containing JupyterLab.

  2. Installipywidgets in each kernel’s environment that will use ipywidgets.

For example, if using conda environments, with JupyterLab installed on thebase environment and the kernel installed in an environment calledpyenv,the commands are:

condainstall-nbase-cconda-forgejupyterlab_widgetscondainstall-npyenv-cconda-forgeipywidgets

Installing in classic Jupyter Notebook#

Most of the time, installingipywidgets automatically configures Jupyter Notebook to use widgets. Theipywidgets package does this by depending on thewidgetsnbextension package, which configures the classic Jupyter Notebook to display and use widgets.

If your Jupyter Notebook and the IPython kernel are installed in differentenvironments (for example, separate environments are providing differentPython kernels), then the installation requires two steps:

  1. Install thewidgetsnbextension package in the environmentcontaining the Jupyter Notebook server.

  2. Installipywidgets in each kernel’s environment that will use ipywidgets.

For example, if using conda environments, with Jupyter Notebook installed on thebase environment and the kernel installed in an environment calledpyenv,the commands are:

condainstall-nbase-cconda-forgewidgetsnbextensioncondainstall-npyenv-cconda-forgeipywidgets

Installing into JupyterLab 1 or 2#

To install the JupyterLab extension into JupyterLab 1 or 2, you also need to run the command below ina terminal which requires that you havenodejsinstalled.

For example, if using conda environments, you can install nodejs with:

condainstall-cconda-forgenodejs

Then you can install the labextension:

jupyterlabextensioninstall@jupyter-widgets/jupyterlab-manager

This command defaults to installing the latest version of theipywidgetsJupyterLab extension. Depending on the version of JupyterLab you have installed, youmay need to installan older version.

If you install this extension while JupyterLab is running, you will need torefresh the page or restart JupyterLab before the changes take effect.

Note: A clean reinstall of the JupyterLab extension can be done by firstrunning thejupyterlabclean command which will remove the staging andstatic directories from the lab directory. The location of the lab directorycan be queried by executing the commandjupyterlabpath in your terminal.

Installing into classic Jupyter Notebook 5.2 or earlier#

If you have an old version of Jupyter Notebook installed (version 5.2 orearlier), you may need to manually enable the ipywidgets notebook extensionwith:

jupyternbextensionenable--pywidgetsnbextension

When usingvirtualenv and working inan activated virtual environment, the--sys-prefix option may be requiredto enable the extension and keep the environment isolated (i.e.jupyternbextensionenable--pywidgetsnbextension--sys-prefix).

Frequently Asked Questions#

The issues in theReference milestone on GitHub include many questions, discussions,and answers about ipywidgets.

Question: When I display a widget or interact, I just see some text, such asIntSlider(value=0) orinteractive(children=(IntSlider(value=0,description='x',max=1),Output()),_dom_classes=('widget-interact',)). What is wrong?

Answer: A text representation of the widget is printed if the widget controlis not available. It may mean the widget JavaScript is still loading. If themessage persists in the Jupyter Notebook or JupyterLab, it likely means that thewidgets JavaScript library is either not installed or not enabled. See theinstallation instructions above for setup instructions.

If you see this message in another frontend (for example, a static rendering onGitHub orNBViewer), it may meanthat your frontend doesn’t currently support widgets.