Jupyterlab extension install for Plotly 4.9.0 fails

This is a copy of an issue I posted on Stack Overflow, but now that I’ve found these forums I’ll repost here.

I’m trying to install Plotly for use within a Jupyter Lab environment using the instructions from Plotly’s web site Instructions. I’m installing on top of a fresh Anaconda 64-bit install on a Windows 10 OS. The following install commands all worked correctly

conda install -c plotly plotly=4.9.0
conda install "notebook>=5.3" "ipywidgets>=7.2"
conda install jupyterlab "ipywidgets=7.5"

I also installed nodejs using:

conda install nodejs

But when it comes time to do the Jupyter Lab specific stuff then this fails

jupyter labextension install jupyterlab-plotly@4.9.0
An error occured.
ValueError: "jupyterlab-plotly@4.9.0" is not a valid npm package
See the log file for details:  C:\Users\tj\AppData\Local\Temp\jupyterlab-debug-cm_yk8nr.log

The log file says the following:

Node v10.13.0

Yarn configuration loaded.
> C:\Users\tj\Anaconda3\npm.CMD pack jupyterlab-plotly@4.9.0
npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning SELF_SIGNED_CERT_IN_CHAIN: request to https://registry.npmjs.org/jupyterlab-plotly failed, reason: self signed certificate in certificate chain
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
npm ERR! code ETARGET
npm ERR! notarget No matching version found for jupyterlab-plotly@4.9.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\tj\AppData\Roaming\npm-cache\_logs\2020-08-25T14_44_35_633Z-debug.log

So all indications to me are that it thinks it can’t find the nodejs package called jupyterlab-plotly. If I go to the NPM site I can find the package jupyterlab-plotly which indicates it’s version 4.9.0.

It’s not clear to me where I’ve gone wrong. Has anyone successfully followed these steps and gotten plotly to work properly in a Jupyter Lab environment?

With the release of plotly 4.10 this issue still continues to happen. The command

jupyter labextension install jupyterlab-plotly@4.10.0

still fails in a similar manner with the error message

An error occured.
ValueError: "jupyterlab-plotly@4.10.0" is not a valid npm package    
See the log file for details:  C:\Users\tj\AppData\Local\Temp\jupyterlab-debug-xbf4irk3.log

and the log file contains info similar to the original one I posted.

I made some progress on this . From my Anaconda prompt I issued a

npm config set registry http://registry.npmjs.org/

command. Then I ran

jupyter labextension install jupyterlab-plotly@4.10.0

which again failed. Looking at it’s debug log things made some progress. It at least found the npm package but when trying to install it we had another issue:

Node v10.13.0

Yarn configuration loaded.
Building jupyterlab assets (build:prod:minimize)
> node C:\Users\tj\Anaconda3\lib\site-packages\jupyterlab\staging\yarn.js install --non-interactive
yarn install v1.21.1
[1/5] Validating package.json...
[2/5] Resolving packages...
error Couldn't find package "plotly.js@^1.55.2" required by "jupyterlab-plotly@file:../extensions/jupyterlab-plotly
4.10.0.tgz" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Error: Couldn't find package "@types/plotly.js@1.44.28" required by "jupyterlab-plotly@file:../extensions/jupyterlab- 
plotly-4.10.0.tgz" on the "npm" registry.
at C:\Users\tj\Anaconda3\share\jupyter\lab\staging\yarn.js:38113:17
at Generator.throw (<anonymous>)
at step (C:\Users\tj\Anaconda3\share\jupyter\lab\staging\yarn.js:310:30)
at C:\Users\tj\Anaconda3\share\jupyter\lab\staging\yarn.js:323:13
at process._tickCallback (internal/process/next_tick.js:68:7)

npm dependencies failed to install

So it looks like it couldn’t find plotly.js. So I then ran

npm install plotly.js

which looks like it succeeded.

npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\tj\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\tj\package.json'
npm WARN tj No description
npm WARN tj No repository field.
npm WARN tj No README data
npm WARN tj No license field.

+ plotly.js@1.55.2
added 453 packages from 166 contributors and audited 454 packages in 30.7s
found 0 vulnerabilities

But another round of

jupyter labextension install jupyterlab-plotly@4.10.0

still fails with the debug log saying again that it can’t find plotly.js (same as above).

I have this problem all the time. I have written a read me to help me install plotly on jupyterlab. I’m going to paste it below. Hopefully it will be helpful for you. I don’t usually use an anaconda environment, but I think this should work there as well. I’m on a MAC for what it’s worth.

#####installing plotly for jupyter lab

#check the version of jupyter lab with
jupyter --v
#jupyter lab should be > 1.2

pip install “ipywidgets==7.5”

#Need to install nodejs and npm
#first install npm
touch ~/.bash_profile
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
#and activate it
. ~/.nvm/nvm.sh
#now use NPM to install nodejs
nvm install 13.12.0

#configure the jupyter lab extensions needed to use plotly

#use this to manage out of memory errors
export NODE_OPTIONS=–max-old-space-size=4096
#install the wigest extension
jupyter labextension install @jupyter-widgets/jupyterlab-manager --no-build
#install the figurewiget
jupyter labextension install plotlywidget@1.5.0 --no-build
#rendering support
jupyter labextension install jupyterlab-plotly --no-build
#build the extensions
jupyter lab build

#unset the node options

Thanks for the info. I was about to walk through your process when I made a last ditch attempt to run

jupyter labextension install jupyterlab-plotly@4.10.0

This time it worked. The only difference is that instead of being attached to my internal corporate network I was attached via VPN. Apparently there’s a difference in the firewalls. I’ll mark this as closed for now.

1 Like

Your process worked for me, except that I got an error on the lab build:
error icss-utils@5.1.0: The engine "node" is incompatible with this module. Expected version "^10 || ^12 || >= 14".

I switched to 12.22.1 (nvm install 12.22.1) and then it worked. Thanks!