Skip to content

Commit

Permalink
Remove more references to jupyterlab-plotly
Browse files Browse the repository at this point in the history
  • Loading branch information
marthacryan committed Oct 22, 2024
1 parent cb488ff commit 4096595
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 128 deletions.
18 changes: 6 additions & 12 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ jobs:
. venv/bin/activate
pip install --upgrade pip wheel
pip install -r ./test_requirements/requirements_38_core.txt black inflect
pip install jupyterlab~=3.0
pip install jupyterlab
- run:
name: Update jupyterlab-plotly and jupyter widget plotly.js version
name: Update jupyter widget plotly.js version
command: |
cd packages/python/plotly
. venv/bin/activate
Expand Down Expand Up @@ -398,7 +398,7 @@ jobs:
conda config --remove channels defaults
conda config --add channels conda-forge
conda create -n env --yes python=3.9 conda-build=3.28.4 conda-verify
conda install -n env -c conda-forge jupyterlab=3 nodejs=16
conda install -n env -c conda-forge jupyterlab nodejs=16
conda init bash
mkdir output
Expand All @@ -407,9 +407,8 @@ jobs:
command: |
eval "$(conda shell.bash hook)"
conda activate env
cd packages/javascript/jupyterlab-plotly
npm ci
npm run build:prod
cd packages/python/plotly/js
npm run build
git status
- run:
Expand Down Expand Up @@ -437,12 +436,7 @@ jobs:
command: |
eval "$(conda shell.bash hook)"
conda activate env
cd packages/javascript/jupyterlab-plotly
npm pack
mv jupyterlab-plotly*.tgz ../../../output
cd ../../python/plotly/js
npm run build
mv ../bundle.js ../../../../output
mv packages/python/plotly/bundle.js ../../../../output
- run:
name: Zip output
Expand Down
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,26 +111,21 @@ conda install "jupyterlab>=3" "ipywidgets>=7.6"

The instructions above apply to JupyterLab 3.x. **For JupyterLab 2 or earlier**, run the following commands to install the required JupyterLab extensions (note that this will require [`node`](https://nodejs.org/) to be installed):

```
# JupyterLab 2.x renderer support
jupyter labextension install jupyterlab-plotly@5.24.1 @jupyter-widgets/jupyterlab-manager
```

Please check out our [Troubleshooting guide](https://plotly.com/python/troubleshooting/) if you run into any problems with JupyterLab.

### Jupyter Notebook Support
### Jupyter Widget Support

For use in the Jupyter Notebook, install the `notebook` and `ipywidgets`
For use as a Jupyter widget, install `jupyter` and `anywidget`
packages using `pip`:

```
pip install "notebook>=5.3" "ipywidgets>=7.5"
pip install jupyter anywidget
```

or `conda`:

```
conda install "notebook>=5.3" "ipywidgets>=7.5"
conda install jupyter anywidget
```

### Static Image Export
Expand Down
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ make that pull request!


## Update to a new version of Plotly.js
First update the version of the `plotly.js` dependency in `packages/javascript/jupyterlab-plotly/package.json`.
First update the version of the `plotly.js` dependency in `packages/python/plotly/js/package.json`.

Then run the `updateplotlyjs` command with:

Expand Down
15 changes: 3 additions & 12 deletions doc/python/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,16 @@ IFrame(snippet_url + 'getting-started', width='100%', height=1200)

#### JupyterLab Support

To use `plotly` in [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/), install the `jupyterlab` and `ipywidgets` packages in the same environment as you installed `plotly`, using `pip`:
To use `plotly` in [JupyterLab](https://jupyterlab.readthedocs.io/en/stable/), install the `jupyterlab` and `anywidget` packages in the same environment as you installed `plotly`, using `pip`:

```
$ pip install "jupyterlab>=3" "ipywidgets>=7.6"
$ pip install jupyterlab anywidget
```

or `conda`:

```
$ conda install "jupyterlab>=3" "ipywidgets>=7.6"
```

The `plotly` jupyterlab extension is included when you install `plotly` using `pip` or `conda`. When you run Jupyter Lab, ensure you are running it in the same environment that you installed `plotly` in so it has access to the `plotly` jupyterlab extension.

**JupyterLab 2 or earlier** does not support the prebuilt extensions installed using `pip` and `conda`. If you are using JupyterLab 2, run the following command to install the required JupyterLab extensions (note that this will require [`node`](https://nodejs.org/) to be installed):

```
# JupyterLab 2.x renderer support
jupyter labextension install jupyterlab-plotly@5.22.0 @jupyter-widgets/jupyterlab-manager
$ conda install jupyterlab anywidget
```

Launch JupyterLab with:
Expand Down
81 changes: 0 additions & 81 deletions doc/python/troubleshooting.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,87 +68,6 @@ IFrame(snippet_url + 'renderers', width='100%', height=1200)
<div style="font-size: 0.9em;"><div style="width: calc(100% - 30px); box-shadow: none; border: thin solid rgb(229, 229, 229);"><div style="padding: 5px;"><div><p><strong>Sign up for Dash Club</strong> → Free cheat sheets plus updates from Chris Parmer and Adam Schroeder delivered to your inbox every two months. Includes tips and tricks, community apps, and deep dives into the Dash architecture.
<u><a href="https://go.plotly.com/dash-club?utm_source=Dash+Club+2022&utm_medium=graphing_libraries&utm_content=inline">Join now</a></u>.</p></div></div></div></div>

<!-- #region -->
### JupyterLab Problems

In order to use `plotly` in JupyterLab, you *must have the `jupyterlab-plotly` extension installed* as detailed in the [Getting Started guide](/python/getting-started). When you install `plotly`, this extension is automatically made available to any JupyterLab 3.x installation in the same Python environment.

To list your current extensions, run the following command in a terminal shell **from the same environment as JupyterLab is launched**:

```bash
# Check that jupyterlab-plotly is installed
$ jupyter labextension list
```

Please note that the *extension version matters*: the extension versions in the [Getting Started](/python/getting-started) guide match the version of `plotly` at the top of the guide and so they should be installed together. Note also that these extensions are meant to work with JupyterLab 1 or above but not 0.x.

If automatic installation of the extension is not working in your environment, or if you are using JupyterLab 1.x or 2.0, you may install it manually using the following command, which requires `node` to be installed.

```bash
# Manually reinstall the extension
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyterlab-plotly
```

If you have [installed additional python environments](https://ipython.readthedocs.io/en/stable/install/kernel_install.html) (or kernels) to use with JupyterLab, or if you are using a centrally hosted JupyterLab installation, you need to make sure that the extensions are installed in the python environment used to launch JupyterLab (the "server" environment). If you accidentally installed the extensions (and run the command above) in one of the additional python environments ("processing" environments), then it is possible for the command above to list the correct extensions but for them to not be available in the JupyterLab front-end you have loaded in your browser. To check if this is the problem, you can [look at the active extension list through your browser via the JupyterLab Extension Manager](https://jupyterlab.readthedocs.io/en/stable/user/extensions.html#using-the-extension-manager), which will always list the extensions in the "server" environment. To summarize: if you use JupyterLab with multiple python environments, the extensions must be installed in the "server" environment, and the plotly python library must be installed in each "processing" environment that you intend to use.

> Note that version 4.14.3 of `plotly` or earlier needed two extensions (`jupyterlab-plotly` and `plotlywidget`) to be installed manually running, and that `plotlywidget` requires `@jupyter-widgets/jupyterlab-manager` to be installed:
```bash
# Instructions for `plotly` 4.x
$ jupyter labextension install jupyterlab-plotly plotlywidget @jupyter-widgets/jupyterlab-manager
```

If you have the correct version(s) of the extension(s) installed and active in your active JupyterLab sessions and are still seeing problems, the issue may clear up if you rebuild JupyterLab. This shouldn't be required in principle but some users have resolved their issues this way. To rebuild JupyterLab, shut down JupyterLab and run the following command in a terminal shell **from the same environment as JupyterLab was launched**:

```bash
# rebuilding JupyterLab
$ jupyter lab build
```

To uninstall your Plotly extensions prior to reinstalling them, run the following commands in a terminal shell before reinstalling them by following the instructions in the [Getting Started guide](/python/getting-started):

```bash
# uninstalling extensions to reinstall
$ jupyter labextension uninstall jupyterlab-plotly
$ jupyter labextension uninstall plotlywidget
```

If you run into "out of memory" problems while installing the extensions or building JupyterLab, try running these commands before running `jupyter labextension install`...

```bash
# Avoid "JavaScript heap out of memory" errors during extension installation
# (OS X/Linux)
export NODE_OPTIONS=--max-old-space-size=4096
# (Windows)
set NODE_OPTIONS=--max-old-space-size=4096
```

...and these commands afterwards.

```bash
# Unset NODE_OPTIONS environment variable
# (OS X/Linux)
unset NODE_OPTIONS
# (Windows)
set NODE_OPTIONS=
```

### Jupyter Classic Notebook Problems

The classic Jupyter Notebook (i.e. launched with `jupyter notebook`) sometimes suffers from a problem whereby if you close the window and reopen it, your plots render as blank spaces.

The easiest solution is to force the `notebook` renderer to reload by calling `fig.show("notebook")` instead of just `fig.show()`.

If this problem is recurrent, you may safely run the following code in a Notebook (not in JupyterLab!) at any time and it should restore your figures (for example, you may put it at the top of your notebook for easy access):

```python
import plotly.io as pio
pio.renderers.default='notebook'
```

As a last resort, you can "Restart & Clear Output" from the Kernel menu and rerun your notebook.

<!-- #endregion -->

### VSCode Notebook, Nteract and Streamlit Problems

Expand Down
1 change: 0 additions & 1 deletion packages/python/plotly/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
include LICENSE.txt
include README.md
include jupyterlab-plotly.json
include versioneer.py
include plotly/_version.py
include plotly/bundle.js
1 change: 0 additions & 1 deletion packages/python/plotly/js/widget.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// Adapted from ../../../javascript/jupyterlab-plotly/src/Figure.ts for anywidget.
import type { DOMWidgetModel } from "@jupyter-widgets/base";
import _ from "lodash";
import Plotly from "plotly.js";
Expand Down
15 changes: 4 additions & 11 deletions packages/python/plotly/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

here = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(os.path.dirname(os.path.dirname(here)))
node_root = os.path.join(project_root, "packages", "javascript", "jupyterlab-plotly")
node_root = os.path.join(project_root, "packages", "python", "plotly", "js")
is_repo = os.path.exists(os.path.join(project_root, ".git"))

npm_path = os.pathsep.join(
Expand Down Expand Up @@ -99,9 +99,7 @@ class NPM(Command):
node_modules = os.path.join(node_root, "node_modules")

targets = [
os.path.join(here, "jupyterlab_plotly", "nbextension", "extension.js"),
os.path.join(here, "jupyterlab_plotly", "nbextension", "index.js"),
os.path.join(here, "jupyterlab_plotly", "labextension", "package.json"),
os.path.join(here, "bundle.js"),
]

def initialize_options(self):
Expand All @@ -125,11 +123,6 @@ def has_npm(self):
except:
return False

def should_run_npm_install(self):
package_json = os.path.join(node_root, "package.json")
node_modules_exists = os.path.exists(self.node_modules)
return self.has_npm()

def run(self):
if skip_npm:
log.info("Skipping npm-installation")
Expand All @@ -144,7 +137,7 @@ def run(self):
env = os.environ.copy()
env["PATH"] = npm_path

if self.should_run_npm_install():
if self.has_npm():
log.info(
"Installing build dependencies with npm. This may take a while..."
)
Expand All @@ -164,7 +157,7 @@ def run(self):
stderr=sys.stderr,
)
check_call(
[npmName, "run", "build:prod"],
[npmName, "run", "build"],
cwd=node_root,
stdout=sys.stdout,
stderr=sys.stderr,
Expand Down

0 comments on commit 4096595

Please sign in to comment.