查看: 1654|回复: 1

pip安装错误:ImportError: No module named 'pkg_resources'

[复制链接]

38

主题

84

帖子

243

积分

中级会员

Rank: 3Rank: 3

积分
243
发表于 2019-2-8 16:39:56 | 显示全部楼层 |阅读模式
本帖最后由 lsh 于 2019-2-8 16:42 编辑

今天在Ubuntu 16.4 LTS 系统上使用pip install -U [Some Package]来更新Python上安装的包,但是在更新的过程中突然出现了错误,造成错误的核心是:

    ‘_NamespacePath’ object has no attribute ‘sort’

并且无论调用pip的任何命令都会出现错误,并且通过Ubuntu中的apt-get install python3-pip重新安装pip时,会提示已经安装过,但是调用后同样会出现上面的异常,通过各种查资料,最后解决了这个问题,因此Mark一下,以备不时之需,那么解决方法如下。

解决方法
步骤1. 重新安装setuptools模块


[1]. 下载—–从pypi网站上下载setuptools的安装压缩包,点击跳转 / 点击直接下载zip包
[2]. 解压—–使用unzip相关命令解压下载下来的zip安装包,当然也可以使用其他方式。
[3]. 安装—–进入解压后的文件夹,查看当前目录下是否有名为setup.py的文件,使用python setup.py install命令完成setuptools的重新安装。

步骤2. 重新安装pip模块

安装完成好setuptools后就可以使用easy_install命令了,这样我们就可以重新安装pip了。使用如下命令安装easy_install pip安装完成后就可以正常的使用pip了。



步骤3.  Finally,  try this:

  • easy_install distribute
  • pip install --upgrade distribute


[Also, there are many other methods introduced in Internet. However, many of them do not work well. This is a feasible solution.]


回复

使用道具 举报

38

主题

84

帖子

243

积分

中级会员

Rank: 3Rank: 3

积分
243
 楼主| 发表于 2019-2-8 20:13:06 | 显示全部楼层
using

sudo easy_install pip

please do not forget sudo
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表