Score:-1

sudo: jupyter: command not found & OSError: [Errno 13] Permission denied: '/usr/local/share/jupyter'

bh flag

If I try to check if jupyter is in my path or not using, I get something in return.

which jupyter
/home/usr/.local/bin/jupyter

But when I try to install and enable an extension, I face error:

sudo jupyter serverextension enable --py ipyparallel
sudo jupyter nbextension install --py ipyparallel
sudo jupyter nbextension enable --py ipyparallel

The error says sudo: jupyter: command not found

And I need sudo access. Cause executing without sudo, doesn't get the job done:

jupyter serverextension enable --py ipyparallel
jupyter nbextension install --py ipyparallel 
jupyter nbextension enable --py ipyparallel 
Enabling: ipyparallel.nbextension
- Writing config: /home/usr/.jupyter
    - Validating...
      ipyparallel.nbextension  OK
Installing /home/usr/.local/lib/python2.7/site-packages/ipyparallel/nbextension/static -> ipyparallel
Traceback (most recent call last):
  File "/home/usr/.local/bin/jupyter-nbextension", line 8, in <module>
    sys.exit(main())
  File "/home/usr/.local/lib/python2.7/site-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/home/usr/.local/lib/python2.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/home/usr/.local/lib/python2.7/site-packages/notebook/nbextensions.py", line 988, in start
    super(NBExtensionApp, self).start()
  File "/home/usr/.local/lib/python2.7/site-packages/jupyter_core/application.py", line 259, in start
    self.subapp.start()
  File "/home/usr/.local/lib/python2.7/site-packages/notebook/nbextensions.py", line 716, in start
    self.install_extensions()
  File "/home/usr/.local/lib/python2.7/site-packages/notebook/nbextensions.py", line 695, in install_extensions
    **kwargs
  File "/home/usr/.local/lib/python2.7/site-packages/notebook/nbextensions.py", line 225, in install_nbextension_python
    destination=dest, logger=logger
  File "/home/usr/.local/lib/python2.7/site-packages/notebook/nbextensions.py", line 126, in install_nbextension
    ensure_dir_exists(nbext)
  File "/home/usr/.local/lib/python2.7/site-packages/jupyter_core/utils/__init__.py", line 13, in ensure_dir_exists
    os.makedirs(path, mode=mode)
  File "/usr/lib/python2.7/os.py", line 150, in makedirs
    makedirs(head, mode)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/local/share/jupyter'
Enabling tree extension ipyparallel/main...
      - Validating: OK

In this(^) case, the error says : OSError: [Errno 13] Permission denied: '/usr/local/share/jupyter'

So how can I fix this?

I've added export PATH="$HOME/.local/bin:$PATH" at the last line of ~/.bashrc

muru avatar
us flag
Try installing *without* `sudo` but with `--user`.
Score:0
cn flag

When you use sudo, a different environment is in effect. Accordingly, your private bin folder (/home/usr/.local/bin/jupyter) is not anymore in the search path, and the command is not anymore found.

The path that is in effect is defined in the sudoers file. On Ubuntu, it appears as:

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin

Thus, install your binary in (/usr/local/bin) for it to be found when running it through the sudo command. By convention, that is the directory aimed for manually installed executables, i.e., manually managed by the administrator rather than automatically by the distribution.

Alternatively, keep the binary where it is and use the -E option of the sudo command. That preserves your current environment, including the path. Some thoughts: 1) the operating system must allow that (Ubuntu does), 2) if possible, it is better practice to stay out of your own user folder for operations requiring root permissions and 3) certainly do not run graphic programs this way because it may mess up permissions.

vanadium avatar
cn flag
@steeldriver OK, some research indeed suggests that sudo uses a path defined in the sudoers file. I will update my answer.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.