You are not logged in.

#1 2019-02-09 00:57:58

miomio
Member
Registered: 2016-01-17
Posts: 93

[SOLVED] Broke jupyter-lab after trying to install extensions

Here's the terminal output:

$ jupyter-labextension list
JupyterLab v0.35.4
No installed extensions

$ jupyter labextension install @jupyterlab/latex
Node v11.9.0


Errored, use --debug for full output:
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.7/site-packages/jupyterlab/extensions'

$ sudo !!
sudo jupyter labextension install @jupyterlab/latex
[sudo] password for chonk:
Node v11.9.0

> /usr/bin/npm pack @jupyterlab/latex
npm notice
npm notice ?  @jupyterlab/latex@0.6.1
npm notice === Tarball Contents ===
npm notice 2.2kB  package.json
npm notice 1.5kB  LICENSE
npm notice 2.4kB  README.md
npm notice 739B   lib/error.d.ts
npm notice 1.4kB  lib/error.js
npm notice 633B   lib/index.d.ts
npm notice 19.0kB lib/index.js
npm notice 362B   lib/pagenumber.d.ts
npm notice 3.8kB  lib/pagenumber.js
npm notice 3.9kB  lib/pdf.d.ts
npm notice 15.1kB lib/pdf.js
npm notice 401B   schema/plugin.json
npm notice 600B   style/fit_dark.svg
npm notice 600B   style/fit_light.svg
npm notice 2.5kB  style/index.css
npm notice 213B   style/next_dark.svg
npm notice 213B   style/next_light.svg
npm notice 210B   style/previous_dark.svg
npm notice 210B   style/previous_light.svg
npm notice 450B   style/zoom_in_dark.svg
npm notice 450B   style/zoom_in_light.svg
npm notice 411B   style/zoom_out_dark.svg
npm notice 411B   style/zoom_out_light.svg
npm notice === Tarball Details ===
npm notice name:          @jupyterlab/latex
npm notice version:       0.6.1
npm notice filename:      jupyterlab-latex-0.6.1.tgz
npm notice package size:  14.7 kB
npm notice unpacked size: 57.6 kB
npm notice shasum:        cd05d10b794f5a81f31d42477d61cb4e7b118327
npm notice integrity:     sha512-4f5hRvvdQQNej[...]ujSx520A7E7PA==
npm notice total files:   23
npm notice
jupyterlab-latex-0.6.1.tgz
Node v11.9.0


Errored, use --debug for full output:
shutil.SameFileError: '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' and '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' are the same file

$ sudo jupyter labextension check

$ sudo jupyter labextension list
JupyterLab v0.35.4
Known labextensions:
   app dir: /usr/lib/python3.7/site-packages/jupyterlab
        @jupyterlab/latex v0.6.1  enabled  OK

Build recommended, please run `jupyter lab build`:
    @jupyterlab/latex needs to be included in build

$ sudo jupyter labextension install @mflevine/jupyterlab_html
Node v11.9.0

> /usr/bin/npm pack @mflevine/jupyterlab_html
npm notice
npm notice ?  @mflevine/jupyterlab_html@0.1.4
npm notice === Tarball Contents ===
npm notice 1.1kB package.json
npm notice 1.5kB LICENSE
npm notice 770B  README.md
npm notice 963B  lib/index.d.ts
npm notice 3.5kB lib/index.js
npm notice 681B  style/html5-icon.svg
npm notice 1.1kB style/index.css
npm notice === Tarball Details ===
npm notice name:          @mflevine/jupyterlab_html
npm notice version:       0.1.4
npm notice filename:      mflevine-jupyterlab_html-0.1.4.tgz
npm notice package size:  4.2 kB
npm notice unpacked size: 9.7 kB
npm notice shasum:        a71d2f85131efacf94c545d19629bead3dbd7951
npm notice integrity:     sha512-rcH1v4grQ+4Sh[...]zmQM0mXr3FKiw==
npm notice total files:   7
npm notice
mflevine-jupyterlab_html-0.1.4.tgz
Node v11.9.0


Errored, use --debug for full output:
shutil.SameFileError: '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' and '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' are the same file

$ sudo jupyter labextension list
JupyterLab v0.35.4
Known labextensions:
   app dir: /usr/lib/python3.7/site-packages/jupyterlab
        @jupyterlab/latex v0.6.1  enabled  OK
        @mflevine/jupyterlab_html v0.1.4  enabled  OK

Build recommended, please run `jupyter lab build`:
    @jupyterlab/latex needs to be included in build
    @mflevine/jupyterlab_html needs to be included in build

$ sudo jupyter labextension install @jupyterlab/plotly-extension
Node v11.9.0

> /usr/bin/npm pack @jupyterlab/plotly-extension
npm notice
npm notice ?  @jupyterlab/plotly-extension@0.18.2
npm notice === Tarball Contents ===
npm notice 1.2kB package.json
npm notice 1.5kB LICENSE
npm notice 2.4kB README.md
npm notice 1.3kB lib/index.d.ts
npm notice 3.7kB lib/index.js
npm notice 546B  style/index.css
npm notice 1.7kB style/plotly.svg
npm notice === Tarball Details ===
npm notice name:          @jupyterlab/plotly-extension
npm notice version:       0.18.2
npm notice filename:      jupyterlab-plotly-extension-0.18.2.tgz
npm notice package size:  4.7 kB
npm notice unpacked size: 12.4 kB
npm notice shasum:        146b2a2eb83e6b9ee2b1cb62fe4913dd3ebb2674
npm notice integrity:     sha512-LadmZ3YQWaE7d[...]dUaEDoBlxtnbQ==
npm notice total files:   7
npm notice
jupyterlab-plotly-extension-0.18.2.tgz
Node v11.9.0


Errored, use --debug for full output:
shutil.SameFileError: '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' and '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' are the same file

$ jupyter lab build
[LabBuildApp] JupyterLab 0.35.4
[LabBuildApp] Cleaning /usr/lib/python3.7/site-packages/jupyterlab
Cleaning /usr/lib/python3.7/site-packages/jupyterlab...
Success!
[LabBuildApp] Building in /usr/lib/python3.7/site-packages/jupyterlab
[LabBuildApp] Node v11.9.0

Traceback (most recent call last):
  File "/usr/bin/jupyter-lab", line 11, in <module>
    load_entry_point('jupyterlab==0.35.4', 'console_scripts', 'jupyter-lab')()
  File "/usr/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/lib/python3.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/lib/python3.7/site-packages/notebook/notebookapp.py", line 1758, in start
    super(NotebookApp, self).start()
  File "/usr/lib/python3.7/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/usr/lib/python3.7/site-packages/jupyterlab/labapp.py", line 78, in start
    command=command, logger=self.log)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 274, in build
    command=command, clean_staging=clean_staging)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 446, in build
    clean=clean_staging
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 871, in _populate_staging
    shutil.copy(pjoin(HERE, 'staging', fname), target)
  File "/usr/lib/python3.7/shutil.py", line 245, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.7/shutil.py", line 104, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' and '/usr/lib/python3.7/site-packages/jupyterlab/staging/index.js' are the same file

$ sudo !!
sudo jupyter lab build
[LabBuildApp] JupyterLab 0.35.4
[LabBuildApp] Cleaning /usr/lib/python3.7/site-packages/jupyterlab
Cleaning /usr/lib/python3.7/site-packages/jupyterlab...
Success!
[LabBuildApp] Building in /usr/lib/python3.7/site-packages/jupyterlab
internal/modules/cjs/loader.js:611
    throw err;
    ^

Error: Cannot find module './staging/package.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:609:15)
    at Function.Module._load (internal/modules/cjs/loader.js:535:25)
    at Module.require (internal/modules/cjs/loader.js:663:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/lib/python3.7/site-packages/jupyterlab/node-version-check.js:2:11)
    at Module._compile (internal/modules/cjs/loader.js:734:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:745:10)
    at Module.load (internal/modules/cjs/loader.js:626:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:566:12)
    at Function.Module._load (internal/modules/cjs/loader.js:558:3)
Traceback (most recent call last):
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 1483, in _node_check
    output = subprocess.check_output([node, 'node-version-check.js'], cwd=HERE)
  File "/usr/lib/python3.7/subprocess.py", line 395, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.7/subprocess.py", line 487, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/bin/node', 'node-version-check.js']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/jupyter-lab", line 11, in <module>
    load_entry_point('jupyterlab==0.35.4', 'console_scripts', 'jupyter-lab')()
  File "/usr/lib/python3.7/site-packages/jupyter_core/application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/lib/python3.7/site-packages/traitlets/config/application.py", line 658, in launch_instance
    app.start()
  File "/usr/lib/python3.7/site-packages/notebook/notebookapp.py", line 1758, in start
    super(NotebookApp, self).start()
  File "/usr/lib/python3.7/site-packages/jupyter_core/application.py", line 255, in start
    self.subapp.start()
  File "/usr/lib/python3.7/site-packages/jupyterlab/labapp.py", line 78, in start
    command=command, logger=self.log)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 271, in build
    _node_check(logger)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 1486, in _node_check
    data = _get_core_data()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 1589, in _get_core_data
    with open(pjoin(HERE, 'staging', 'package.json')) as fid:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.7/site-packages/jupyterlab/staging/package.json'

$ jupyter labextension list
Traceback (most recent call last):
  File "/usr/bin/jupyter-labextension", line 11, in <module>
    load_entry_point('jupyterlab==0.35.4', 'console_scripts', 'jupyter-labextension')()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.7/site-packages/jupyterlab/labextensions.py", line 53, in <module>
    VERSION = get_app_version()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 348, in get_app_version
    handler = _AppHandler(app_dir)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 386, in __init__
    self.info = self._get_app_info()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 808, in _get_app_info
    info['core_data'] = core_data = _get_core_data()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 1589, in _get_core_data
    with open(pjoin(HERE, 'staging', 'package.json')) as fid:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.7/site-packages/jupyterlab/staging/package.json'

$ jupyter labextension help
Traceback (most recent call last):
  File "/usr/bin/jupyter-labextension", line 11, in <module>
    load_entry_point('jupyterlab==0.35.4', 'console_scripts', 'jupyter-labextension')()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.7/site-packages/jupyterlab/labextensions.py", line 53, in <module>
    VERSION = get_app_version()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 348, in get_app_version
    handler = _AppHandler(app_dir)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 386, in __init__
    self.info = self._get_app_info()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 808, in _get_app_info
    info['core_data'] = core_data = _get_core_data()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 1589, in _get_core_data
    with open(pjoin(HERE, 'staging', 'package.json')) as fid:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.7/site-packages/jupyterlab/staging/package.json'

$ jupyter labextension --help
Traceback (most recent call last):
  File "/usr/bin/jupyter-labextension", line 11, in <module>
    load_entry_point('jupyterlab==0.35.4', 'console_scripts', 'jupyter-labextension')()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.7/site-packages/jupyterlab/labextensions.py", line 53, in <module>
    VERSION = get_app_version()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 348, in get_app_version
    handler = _AppHandler(app_dir)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 386, in __init__
    self.info = self._get_app_info()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 808, in _get_app_info
    info['core_data'] = core_data = _get_core_data()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 1589, in _get_core_data
    with open(pjoin(HERE, 'staging', 'package.json')) as fid:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.7/site-packages/jupyterlab/staging/package.json'

$ jupyter --help
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]

Jupyter: Interactive Computing

positional arguments:
  subcommand     the subcommand to launch

optional arguments:
  -h, --help     show this help message and exit
  --version      show the jupyter command's version and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable
                 format.
  --json         output paths as machine-readable json

Available subcommands: bundlerextension console kernel kernelspec lab
labextension labhub migrate nbconvert nbextension notebook run serverextension
trust

$ jupyter --paths
config:
    /home/chonk/.jupyter
    /usr/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/chonk/.local/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /run/user/1000/jupyter

$ jupyter-lab --help
Traceback (most recent call last):
  File "/usr/bin/jupyter-lab", line 11, in <module>
    load_entry_point('jupyterlab==0.35.4', 'console_scripts', 'jupyter-lab')()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3.7/site-packages/jupyterlab/labapp.py", line 37, in <module>
    app_version = get_app_version()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 348, in get_app_version
    handler = _AppHandler(app_dir)
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 386, in __init__
    self.info = self._get_app_info()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 808, in _get_app_info
    info['core_data'] = core_data = _get_core_data()
  File "/usr/lib/python3.7/site-packages/jupyterlab/commands.py", line 1589, in _get_core_data
    with open(pjoin(HERE, 'staging', 'package.json')) as fid:
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.7/site-packages/jupyterlab/staging/package.json'
  • I tried to install three jupyter lab extensions but looks like I'd already previously run that command hence the npm sameFileError errors.

  • I then ran under my user `jupyter lab build` as the output from the list of extensions recommended it, which was unsuccessful

  • I then ran it with sudo which was again unsuccessful

  • Now it looks like even `jupyter-lab --help` results in an error

How can I correct all of this?

Last edited by miomio (2019-02-10 23:26:17)

Offline

#2 2019-02-09 20:36:39

jagan605
Member
Registered: 2011-12-04
Posts: 26

Re: [SOLVED] Broke jupyter-lab after trying to install extensions

You should take this to heart, “Never run a language package manager as root”. Fixing this would probably require you to find what files were exactly installed and removing them.

If you want to have an extension, look at installing it on a per-user basis or make a package for it.

Offline

#3 2019-02-09 22:16:35

miomio
Member
Registered: 2016-01-17
Posts: 93

Re: [SOLVED] Broke jupyter-lab after trying to install extensions

jagan605 wrote:

You should take this to heart, “Never run a language package manager as root”. Fixing this would probably require you to find what files were exactly installed and removing them.

If you want to have an extension, look at installing it on a per-user basis or make a package for it.

Honestly, I never know when it is OK and not OK to use sudo. If I get a permission error I don't think twice. So you're correct in pointing that out to me. But I suspect many others have a habit of doing the same thing on Linux... Jupyter-lab was installed via the repos so wouldn't you have expected that command not to fail when I first ran it without sudo then?

Perhaps there was some permissions errors that needs correcting after the pacman installation is complete of jupyter-lab that isn't detailed in the wiki? This has escalated from my frivolous use of sudo and having tried but failed first time round due to a permissions error on my non-root user...

As a side issue: another item I find confusing with Python under Arch is: what is the appropriate way to install Python packages, e.g. through pacman or via `python3.7 -m pip install --user <package>` as a non-root user? I do the latter but pacman does offer, for example, beautifulsoup4 from the repos. But of course if you rely on installing from the repos these are installed as system-wide software and surely that creates cascading issues when you want to use virtualenvs and different interpreter versions and different version packages?... Just another thought on top of the issue I've posted about.

Last edited by miomio (2019-02-09 22:22:47)

Offline

#4 2019-02-10 13:34:17

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 7,044

Re: [SOLVED] Broke jupyter-lab after trying to install extensions

Regarding the Jupyter situation, there's a reason the the Jupyter wiki page tells you how to properly prepare for local installation of extensions.

If you indeed did what was detailed there (and if your paths output is anything to go by, you didn't...), and you still get a permissions error then there might indeed be something that should be looked at, however as you noticed, not every "Permission denied" error can be sledgehammered to correctness by simply pasting sudo in front. Regardless of how common it may be, it's a dangerous habit. Especially in the case of different package managers, there's nearly always an option to install locally instead of system wide instead, which should be preferred in these cases.

For the general question: If available as a system package, install the system package. If not you can install them locally. In either case, the entire point of virtualenvs it to be isolated from the rest of the system, so that should explicitly not create cascading issues with whatever other packages there are.

Online

#5 2019-02-10 18:09:47

miomio
Member
Registered: 2016-01-17
Posts: 93

Re: [SOLVED] Broke jupyter-lab after trying to install extensions

V1del wrote:

Regarding the Jupyter situation, there's a reason the the Jupyter wiki page tells you how to properly prepare for local installation of extensions.
...

I'll try that environment variable after reinstalling the software.

`pacman -Rsc jupyterlab` then or just '-R' flag?

EDIT:

Resolved with the user-scope environment variable.

Last edited by miomio (2019-02-10 23:25:34)

Offline

Board footer

Powered by FluxBB