问题描述

使用paddlehub 'hub install '安装jieba_paddle抛异常报 cannot import name 'get_installed_distributions' from 'pip._internal.utils.misc'错误。

报错信息:

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/setuptools/depends.py:2: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import imp
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/__init__.py:107: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import MutableMapping
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/rcsetup.py:20: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Iterable, Mapping
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Sized
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip/_vendor/packaging/version.py:114: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  DeprecationWarning,
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip/_vendor/packaging/version.py:114: DeprecationWarning: Creating a LegacyVersion has been deprecated and will be removed in the next major release
  DeprecationWarning,
Traceback (most recent call last):
  File "/opt/conda/envs/python35-paddle120-env/bin/hub", line 6, in <module>
    from paddlehubmands.utils import execute
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/commands/__init__.py", line 24, in <module>
    import paddlehubmands.install
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/commands/install.py", line 21, in <module>
    from paddlehub.module.manager import LocalModuleManager
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/module/manager.py", line 28, in <module>
    from paddlehub.utils import xarfile, log, utils, pypi
  File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlehub/utils/pypi.py", line 18, in <module>
    from pip._internal.utils.misc import get_installed_distributions
ImportError: cannot import name 'get_installed_distributions' from 'pip._internal.utils.misc' (/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip/_internal/utils/misc.py)

解决方案:

  1. 使用pip -V指令,确定pip的版本。

  2. 我当前的pip版本为:

    pip 21.3.1 from /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip (python 3.7)
    

    使用pip install pip==21.2指令安装21.2版本pip。

  3. 再次使用pip -V指令,查看pip版本。

    pip 21.2.2 from /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/pip (python 3.7)
    
  4. 依次使用下述命令安装

    pip install paddlepaddle
    pip install paddlehub
    hub install jieba_paddle
    

更多推荐

解决: 使用paddlehub 安装jieba_paddle报 cannot import name ‘get_installed_distributions‘