Desinstalar o jupyter com pip

0

Eu tenho o executável jupyter aqui: /usr/local/bin/jupyter

Eu sei historicamente que eu tenho usado Python 2 da distribuição do Ubuntu (não Anaconda), então eu acho que jupyter veio de um sistema pip2 install, mas eu não consigo encontrar uma maneira de provar isso, existe algum?

Assumindo o cenário anterior, eu fiz isso: sudo /usr/local/bin/pip2 uninstall jupyter e este sudo /usr/local/bin/pip2 uninstall notebook (mesmo se em /usr/local/bin , eu ainda preciso de sudo porque parece que todos os arquivos lá pertencem a root , por algum motivo), mas continuo vendo esse executável aqui: /usr/local/bin/jupyter

Além disso: eu sei que jupyter é o afetado porque agora o comando: jupyter notebook fornece essa saída Error executing Jupyter command 'notebook': [Errno 2] No such file or directory .

Como desinstalo? Por que pip2 não está removendo esse arquivo executável?

Editar:

Atualmente vejo isso no meu sistema de arquivos:

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

Ao desatualizar jupyter , vi isso:

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.

Ao desatualizar notebook , vi isso:

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.
    
por TPPZ 27.05.2018 / 13:50

2 respostas

1

Eu desinstalei o jupyter usando as seguintes linhas de código, então tente.

$ 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
    
por varunjha089 25.08.2018 / 13:44
0

Eu tentei reproduzir o seu cenário e não tenho o jupyter instalado. Então, primeiro:

sudo pip2 install jupyter

Ele fez o download do jupyter, bem como de alguns outros pacotes, mas terminou primeiro com algum erro, então, em re-run, repetidamente com:

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

No entanto, parece que pelo menos o executável do jupyter já foi instalado:

$ 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

Mas quando eu tentei desinstalá-lo:

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

Caso você tenha o mesmo ao desinstalar, o problema pode ser que o jupyter não tenha sido instalado corretamente em primeiro lugar.

No entanto, finalmente consegui instalá-lo corretamente instalando os cabeçalhos de desenvolvimento do Python: sudo apt install python-dev . E sim, sudo pip2 uninstall jupyter executado com sucesso, mas ainda posso executar /usr/local/bin/jupyter depois disso.

A desinstalação do jupyter-console package (encontrado via pip-autoremove -L ) também não funcionou, mesmo com o nome que alguém possa pensar que deveria.

Mas eu tentei fazer isso em um antigo "Norton Commander", para verificar o que está dentro de /usr/local/bin/jupyter . Felizmente, é apenas um simples código Python, e notei uma referência de pacote interessante na linha 7:

from jupyter_core.command import main

E então foi feito!

$ 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

Portanto, todo o problema é sobre pip não remover em uninstall as dependências que ele baixou automaticamente durante install .

UPDATE: Com relação às mensagens que você encontrou ao desinstalar o jupiter / notebook - não obtive nenhuma delas, mas elas parecem não estar relacionadas ao problema discutido:

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.

Eu também recebo isso se eu executar sudo pip <anything> , não sudo -H pip <anything> . Parece ser inofensivo.

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.

Eu já tenho pip 10.0.1 - é por isso que eu não vejo isso.

Exceto esses avisos, ambos os pacotes estão sendo desinstalados corretamente, como eu posso ver.

Quanto à necessidade de sudo , não estou surpreso, pois normalmente pip install * instala o pacote em todo o sistema e é improvável que você possa gravar em /usr/local/lib/python* sem raiz. O parâmetro --user existe no pip para contornar isso, a resposta mais detalhada está aqui: link

    
por pazhosch 27.05.2018 / 14:33