pylint3 e pip3 quebrados

0

Eu tentei sudo apt remove --purge em vários pacotes. Eu recebo o mesmo quando eu reinstalar.

Eu também tentei reinstalar usando o aptitude. Isso não funciona.

Minha solução atual é executar o pylint3 como root, o que funciona, mas é uma prática ruim.

pip3

    $ pip3
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
    __import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.pkg_resources'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 13, in <module>
    from pip.exceptions import InstallationError, CommandError, PipError
  File "/usr/lib/python3/dist-packages/pip/exceptions.py", line 6, in <module>
    from pip._vendor.six import iteritems
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 75, in <module>
    vendored("pkg_resources")
  File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
    __import__(modulename, globals(), locals(), level=0)
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2927, in <module>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2913, in _call_aside
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 956, in subscribe
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2952, in <lambda>
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2515, in activate
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2097, in declare_namespace
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2047, in _handle_ns
  File "/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
AttributeError: '_NamespacePath' object has no attribute 'sort'

pylint3

$ pylint3
Traceback (most recent call last):
  File "/usr/bin/pylint3", line 3, in <module>
    run_pylint()
  File "/usr/lib/python3/dist-packages/pylint/__init__.py", line 22, in run_pylint
    from pylint.lint import Run
  File "/usr/lib/python3/dist-packages/pylint/lint.py", line 44, in <module>
    import astroid
  File "/usr/lib/python3/dist-packages/astroid/__init__.py", line 54, in <module>
    from astroid.nodes import *
  File "/usr/lib/python3/dist-packages/astroid/nodes.py", line 54, in <module>
    from astroid.scoped_nodes import (
  File "/usr/lib/python3/dist-packages/astroid/scoped_nodes.py", line 35, in <module>
    from astroid import manager
  File "/usr/lib/python3/dist-packages/astroid/manager.py", line 29, in <module>
    from astroid import modutils
  File "/usr/lib/python3/dist-packages/astroid/modutils.py", line 40, in <module>
    import pkg_resources
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
    @_call_aside
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 956, in subscribe
    callback(dist)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2515, in activate
    declare_namespace(pkg)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
    _rebuild_mod_path(path, packageName, module)
  File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
    orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'

atualização Isso consertou isso. %código% Eu adoraria entender como.

atualização de atualização Eu instalei as dependências de que preciso. Então o problema volta.

@ Kenavera Eu estou no mais novo python3-tools do repo (de acordo com o synaptic python3-tools 20.7.0-1, que parece bastante antigo).

executando o python3 como eu, já que o pylint3 na raiz está funcionando. Eu ainda gostaria de uma solução melhor.

    
por ColonelFazackerley 24.02.2018 / 10:16

2 respostas

1

Limpar a instalação do python Restaure a instalação do Python para o padrão mais as dependências do pacote apt

liste todas as coisas manualmente instaladas via apt:

comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)

remova o pylint3 e todo o python3- *. Para mim, isso foi:

sudo apt remove pylint3 python3-googleapi python3-lxml python3-matplotlib python3-numpy python3-pip python3-pyocr python3-scipy python3-tk python-lxml python-numpy python-pip python-setuptools

sudo apt autoremove

listar as coisas instaladas via pip ls -ltd /usr/local/lib/python3.5/dist-packages/*

remova-os

pip3 uninstall setuptools
pip3 uninstall pydicom
pip3 uninstall docx

por último pip-se

pip3 uninstall pip

exclua tudo o que foi instalado para o usuário, excluindo tudo aqui

'$ HOME / .local / lib / python *'

Reinstalar

sudo apt install python3-pip pylint3 python3-venv

Configurar o ambiente virtual

Eu tenho um projeto chamado plan-report. nesse diretório (não como root)

python3 -m venv plan-report-env
chmod +x ./plan-report-env/bin/activate

# this line needs repeating each time a terminal is opened
./plan-report-env/bin/activate

reinstale os pacotes python no ambiente virtual. eg

pip install numpy

Note que foi o python3 que criou o venv, então agora você diz apenas pip , não pip3 . parece ok atualizar o pip dentro do venv também.

pip install --upgrade pip

    
por ColonelFazackerley 15.04.2018 / 08:48
0

sudo apt-get upgrade python-setuptools fez o truque para mim. Espero que isso ajude voçe tambem.

    
por Kenavera 24.02.2018 / 10:21