欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

No module named ‘pip._internal‘

程序员文章站 2022-04-02 11:12:57
问题描述在项目编译过程中出现了错误导致编译中断, 错误提示具体如下:Traceback (most recent call last): File "setup.py", line 219, in if not is_installed('cython_bbox'): File "setup.py", line 177, in is_installed from pip._internal.utils.misc import get_installe...

问题描述

在项目编译过程中出现了错误导致编译中断, 错误提示具体如下:

Traceback (most recent call last):
  File "setup.py", line 219, in <module>
    if not is_installed('cython_bbox'):
  File "setup.py", line 177, in is_installed
    from pip._internal.utils.misc import get_installed_distributions
ModuleNotFoundError: No module named 'pip._internal'

然后在自己的python环境中尝试导入报错如下:

[Muyi@ai-research AlphaPose-master]$ python3
Python 3.6.2 (default, Nov 19 2019, 14:03:45) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pip._internal.utils.misc import get_installed_distributions
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/__init__.py", line 26, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/utils/__init__.py", line 27, in <module>
    from pip._vendor import pkg_resources
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
    @_call_aside
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
    f(*args, **kwargs)
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
    dist.activate(replace=False)
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
    declare_namespace(pkg)
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
    _handle_ns(packageName, path_item)
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
    _rebuild_mod_path(path, packageName, module)
  File "/home/Muyi/Python/Package/python36/lib/python3.6/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2121, in _rebuild_mod_path
    orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'

解决方案

这意味着依赖关系混乱了,尝试了 pip3 install --upgrade setuptools 等一些方法,未能处理这个问题。
最后我通过重新安装 pip 解决了这个问题。

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py

本文地址:https://blog.csdn.net/Noonebirdyou/article/details/110877378

相关标签: Error