'Not able to install Jupyterlab extensions on GCP AI Platform Notebooks
I have started to experience an issue with installing extensions for Jupyterlab that I have not experienced in the past. I am not able to build after installing new extensions for Jupyterlab.
I am running Jupyterlab with GCP AI Platform Notebooks. I am using the standard Python 3 environment on Debian 10. I have tried to run on different types of machines.
I am receiving a status 500 error. Here is the log from when I run jupyter lab build
:
[LabBuildApp] WARNING | Config option `kernel_spec_manager_class` not recognized by `LabBuildApp`.
[LabBuildApp] JupyterLab 1.2.16
[LabBuildApp] Building in /opt/conda/share/jupyter/lab
[LabBuildApp] Building jupyterlab assets (build:prod:minimize)
An error occured.
PermissionError: [Errno 1] Operation not permitted: '/opt/conda/share/jupyter/lab/staging/index.js'
See the log file for details: /tmp/jupyterlab-debug-pnbu3naq.log
Here is the log file with details:
[LabBuildApp] Building in /opt/conda/share/jupyter/lab
[LabBuildApp] Yarn configuration loaded.
[LabBuildApp] Node v15.3.0
[LabBuildApp] Building jupyterlab assets (build:prod:minimize)
[LabBuildApp] Traceback (most recent call last):
[LabBuildApp] File "/opt/conda/lib/python3.7/site-packages/jupyterlab/debuglog.py", line 47, in debug_logging
yield
[LabBuildApp] File "/opt/conda/lib/python3.7/site-packages/jupyterlab/labapp.py", line 98, in start
command=command, app_options=app_options)
[LabBuildApp] File "/opt/conda/lib/python3.7/site-packages/jupyterlab/commands.py", line 459, in build
command=command, clean_staging=clean_staging)
[LabBuildApp] File "/opt/conda/lib/python3.7/site-packages/jupyterlab/commands.py", line 650, in build
clean=clean_staging
[LabBuildApp] File "/opt/conda/lib/python3.7/site-packages/jupyterlab/commands.py", line 1103, in _populate_staging
shutil.copy(pjoin(HERE, 'staging', fname), target)
[LabBuildApp] File "/opt/conda/lib/python3.7/shutil.py", line 249, in copy
copymode(src, dst, follow_symlinks=follow_symlinks)
[LabBuildApp] File "/opt/conda/lib/python3.7/shutil.py", line 144, in copymode
chmod_func(dst, stat.S_IMODE(st.st_mode))
[LabBuildApp] PermissionError: [Errno 1] Operation not permitted: '/opt/conda/share/jupyter/lab/staging/index.js'
[LabBuildApp] Exiting application: JupyterLab
Since I have been able to install the same extensions for Jupyterlab in the past on other VM instances I would expect it has something to do with the version of Jupyterlab that is installed. I would, however, expect that Google would install the latest version of Jupyterlab.
The error log does seem to indicate that it is a permission error, which I don't understand as I am running the jupyter lab build
at base. The only setting I have changed after creating the instance is to enable extensions.
Solution 1:[1]
You need to compile jupyter-lab as root. It's less intuitive because jupyter
is not included in $PATH
for the root user.
Here's what to do:
sudo apt-get install nodejs # needed to compile jupyter-lab
sudo /opt/conda/bin/jupyter lab build
Solution 2:[2]
AI Platform Notebooks are running an old version of JupyterLab. It is hard to install plugins when running an old version. You'll need to move off AI Platform Notebooks or wait until AI Platform Notebooks upgrades to a new version.
AI Platform Notebooks is running 1.x, and the current version is 3.x.
Solution 3:[3]
This is how it proceeded for me.
anu@federation:~$ conda install nodejs
Collecting package metadata (current_repodata.json): failed
NotWritableError: The current user does not have write permissions to a required path.
path: /opt/conda/pkgs/cache/18414ddb.json
uid: 1001
gid: 1002
If you feel that permissions on this path are set incorrectly, you can manually
change them by executing
$ sudo chown 1001:1002 /opt/conda/pkgs/cache/18414ddb.json
In general, it's not advisable to use 'sudo conda'.
anu@federation:~$ sudo chown 1001:1002 /opt/conda/pkgs/cache/*
anu@federation:~$ conda install nodejs
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /opt/conda
added / updated specs:
- nodejs
The following packages will be downloaded:
package | build
---------------------------|-----------------
certifi-2021.10.8 | py37h89c1867_2 145 KB conda-forge
conda-4.12.0 | py37h89c1867_0 1.0 MB conda-forge
jinja2-2.11.3 | pyhd3eb1b0_0 101 KB
openssl-1.1.1o | h166bdaf_0 2.1 MB conda-forge
------------------------------------------------------------
Total: 3.4 MB
The following packages will be UPDATED:
certifi 2021.10.8-py37h89c1867_1 --> 2021.10.8-py37h89c1867_2
conda 4.11.0-py37h89c1867_2 --> 4.12.0-py37h89c1867_0
openssl 1.1.1l-h7f98852_0 --> 1.1.1o-h166bdaf_0
The following packages will be SUPERSEDED by a higher-priority channel:
jinja2 conda-forge::jinja2-2.11.3-pyh44b312d~ --> pkgs/main::jinja2-2.11.3-pyhd3eb1b0_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
openssl-1.1.1o | 2.1 MB | ##################################### | 100%
jinja2-2.11.3 | 101 KB | ##################################### | 100%
certifi-2021.10.8 | 145 KB | ##################################### | 100%
conda-4.12.0 | 1.0 MB | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(base) anu@federation:~$
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
After I saw this error in the log I included additional options like this.
(base) anu@federation:~$ jupyter lab build --dev-build=False --minimize=False
[LabBuildApp] WARNING | Config option `kernel_spec_manager_class` not recognized by `LabBuildApp`.
[LabBuildApp] JupyterLab 3.2.9
[LabBuildApp] Building in /opt/conda/share/jupyter/lab
[LabBuildApp] Building jupyterlab assets (production, not minimized)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Luca Invernizzi |
Solution 2 | Benjamin Atkin |
Solution 3 | Mohan Radhakrishnan |