0

I have the jupyter executable here: /usr/local/bin/jupyter

I know historically I've been using Python 2 from the Ubuntu distribution (no Anaconda) so I think that jupyter came from a system pip2 install, but I can not find a way to prove this, is there any?

Assuming the previous scenario, I've done both this: sudo /usr/local/bin/pip2 uninstall jupyter and this sudo /usr/local/bin/pip2 uninstall notebook (even if in /usr/local/bin, I still need sudo cause it seems all the files in there belong to root, for some reason), but I keep seeing that executable in here: /usr/local/bin/jupyter

Also: I know that jupyter is the affected one because now the command: jupyter notebook gives this output Error executing Jupyter command 'notebook': [Errno 2] No such file or directory.

How do I uninstall it? Why pip2 is not removing that executable file?

Edit:

I currently see this on my filesystem:

ls -lah /usr/local/bin | grep jupyter
-rwxr-xr-x  1 root root  222 May  6  2017 jupyter
-rwxr-xr-x  1 root root  221 May  6  2017 jupyter-console
-rwxr-xr-x  1 root root  264 May  6  2017 jupyter-kernelspec
-rwxr-xr-x  1 root root  222 May  6  2017 jupyter-migrate
-rwxr-xr-x  1 root root  224 May  6  2017 jupyter-nbconvert
-rwxr-xr-x  1 root root  224 May  6  2017 jupyter-qtconsole
-rwxr-xr-x  1 root root  243 May  6  2017 jupyter-run
-rwxr-xr-x  1 root root  227 May  6  2017 jupyter-troubleshoot
-rwxr-xr-x  1 root root  255 May  6  2017 jupyter-trust

When unistalling jupyter I've seen this:

sudo pip2 uninstall jupyter
[sudo] password for <MY_USERNAME>: 
The directory '/home/<MY_USERNAME>/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling jupyter-1.0.0:
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/DESCRIPTION.rst
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/INSTALLER
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/METADATA
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/RECORD
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/WHEEL
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/metadata.json
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/pbr.json
  /usr/local/lib/python2.7/dist-packages/jupyter-1.0.0.dist-info/top_level.txt
  /usr/local/lib/python2.7/dist-packages/jupyter.py
  /usr/local/lib/python2.7/dist-packages/jupyter.pyc
Proceed (y/n)? y
  Successfully uninstalled jupyter-1.0.0
The directory '/home/<MY_USERNAME>/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

When unistalling notebook I've seen this:

sudo pip2 uninstall notebook
The directory '/home/<MY_USERNAME>/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Uninstalling notebook-5.0.0:
  /usr/local/bin/jupyter-bundlerextension
  /usr/local/bin/jupyter-nbextension
  /usr/local/bin/jupyter-notebook
  /usr/local/bin/jupyter-serverextension
  /usr/local/lib/python2.7/dist-packages/notebook-5.0.0.dist-info/DESCRIPTION.rst

  [...]

  /usr/local/lib/python2.7/dist-packages/notebook/tree/tests/__init__.pyc
  /usr/local/lib/python2.7/dist-packages/notebook/tree/tests/test_tree_handler.py
  /usr/local/lib/python2.7/dist-packages/notebook/tree/tests/test_tree_handler.pyc
  /usr/local/lib/python2.7/dist-packages/notebook/utils.py
  /usr/local/lib/python2.7/dist-packages/notebook/utils.pyc
  /usr/local/lib/python2.7/dist-packages/notebook/view/__init__.py
  /usr/local/lib/python2.7/dist-packages/notebook/view/__init__.pyc
  /usr/local/lib/python2.7/dist-packages/notebook/view/handlers.py
  /usr/local/lib/python2.7/dist-packages/notebook/view/handlers.pyc
Proceed (y/n)? y
  Successfully uninstalled notebook-5.0.0
The directory '/home/<MY_USERNAME>/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
0

I have uninstalled the jupyter using the following lines of code so try it.

$ sudo -H python3 -m pip uninstall jupyter_core jupyter_qtconsole nbformat nbconvert notebook

Uninstalling jupyter-core-4.4.0:
      Would remove:
        /usr/bin/jupyter
        /usr/bin/jupyter-migrate
        /usr/bin/jupyter-troubleshoot
        /usr/lib/python3/dist-packages/jupyter.py
        /usr/lib/python3/dist-packages/jupyter_core
        /usr/lib/python3/dist-packages/jupyter_core-4.4.0.egg-info
Uninstalling nbformat-4.4.0:
      Would remove:
        /home/varun/.local/bin/jupyter-trust
        /home/varun/.local/lib/python3.6/site-packages/nbformat-4.4.0.dist-info/*
        /home/varun/.local/lib/python3.6/site-packages/nbformat/*
    Proceed (y/n)? y
      Successfully uninstalled nbformat-4.4.0
Uninstalling nbconvert-5.3.1:
      Would remove:
        /home/varun/.local/bin/jupyter-nbconvert
        /home/varun/.local/lib/python3.6/site-packages/nbconvert-5.3.1.dist-info/*
        /home/varun/.local/lib/python3.6/site-packages/nbconvert/*
    Proceed (y/n)? y
        Successfully uninstalled nbconvert-5.3.1
 Uninstalling notebook-5.6.0:
      Would remove:
        /home/varun/.local/bin/jupyter-bundlerextension
        /home/varun/.local/bin/jupyter-nbextension
        /home/varun/.local/bin/jupyter-notebook
        /home/varun/.local/bin/jupyter-serverextension
        /home/varun/.local/lib/python3.6/site-packages/notebook-5.6.0.dist-info/*
        /home/varun/.local/lib/python3.6/site-packages/notebook/*
    Proceed (y/n)? y
      Successfully uninstalled notebook-5.6.0
0

I've tried to reproduce your scenario, and I don't have jupyter installed. So at first:

sudo pip2 install jupyter

It downloaded jupyter as well as quite a few other packages, but ended first with some stray error, then, on re-run, repeatedly with:

x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c _scandir.c -o build/temp.linux-x86_64-2.7/_scandir.o
    _scandir.c:14:20: fatal error: Python.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

Nevertheless, seems like at least jupyter executable has been already installed:

$ jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]
jupyter: error: one of the arguments --version subcommand --config-dir --data-dir --runtime-dir --paths is required

$ whereis jupyter
jupyter: /usr/local/bin/jupyter

But when I've tried to uninstall it:

sudo -H pip2 uninstall jupyter
Skipping jupyter as it is not installed.

In case you got the same when uninstalling, the problem might be that jupyter haven't been installed correctly at the first place.

However, I was finally able to install it correctly by installing Python dev headers: sudo apt install python-dev. And yes, sudo pip2 uninstall jupyter executed successfully, yet I still could run /usr/local/bin/jupyter after that.

Uninstalling jupyter-console package (found via pip-autoremove -L) didn't do the trick too, even though by name one may think it should.

But then I've tried to do it in an old "Norton Commander" way, to check what's inside /usr/local/bin/jupyter. Luckily, it's just a plain simple Python code, and I've noticed an interesting package reference there at line 7:

from jupyter_core.command import main

And then it was done!

$ jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir]
               [--paths] [--json]
               [subcommand]
jupyter: error: one of the arguments --version subcommand --config-dir --data-dir --runtime-dir --paths is required
$ sudo -H pip2 uninstall jupyter-core
Uninstalling jupyter-core-4.4.0:
  Would remove:
    /usr/local/bin/jupyter
    /usr/local/bin/jupyter-migrate
    /usr/local/bin/jupyter-troubleshoot
    /usr/local/lib/python2.7/dist-packages/jupyter.py
    /usr/local/lib/python2.7/dist-packages/jupyter_core-4.4.0.dist-info/*
    /usr/local/lib/python2.7/dist-packages/jupyter_core/*
Proceed (y/n)? y
  Successfully uninstalled jupyter-core-4.4.0
$ jupyter
bash: /usr/local/bin/jupyter: No such file or directory

So the entire trouble is about pip not removing on uninstall the dependencies it has auto-downloaded during install..

UPDATE: Regarding the messages you've encountered while uninstalling jupiter / notebook - I didn't get any of these, but they seem not to be related to the problem discussed:

The directory '/home//.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

I also get this if I run sudo pip <anything>, not sudo -H pip <anything>. Seems to be harmless.

You are using pip version 9.0.1, however version 10.0.1 is available.  
You should consider upgrading via the 'pip install --upgrade pip' command.

I already have pip 10.0.1 - that's why I don't see this.

Except these warnings, both packages are getting uninstalled correctly, as I can see.

Regarding the need for sudo, I'm not surprised as normally pip install * installs the package system-wide, and it's unlikely you will be able to write to /usr/local/lib/python* without root. The parameter --user exists in pip to get around this, the more detailed answer is here: https://stackoverflow.com/questions/42988977/what-is-the-purpose-pip-install-user

  • I've updated the question with more details. Thanks – TPPZ May 27 '18 at 13:24

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.